Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tan, sin, cos, atan..... Funcionan en pinguino?
24-03-2014, 03:43 PM, (This post was last modified: 24-03-2014, 03:46 PM by kmiz07.)
#1
tan, sin, cos, atan..... Funcionan en pinguino?
No he conseguido encontrar informacion sobre cuales de estas funciones son soportadas por pinguino.
Concretamente me interesarian sin(), cos() y atan(). (arco tangente)
Ademas, no he conseguido encontrar un lugar actualizado donde ver que funciones del ansiC estan o no soportadas.
Existe?, Donde?
Agradecido de antemano.


PD. Disculpen, no vi que escribia fuera de internacional-español.

I have not been able to find information about which of these functions are supported by penguin.
Specifically I would be interested sin (), cos () and atan (). (arctangent)
Besides, I have not managed to find an updated place to see ansiC functions are supported or not.
There?, Where?
Thanked beforehand.
Reply
24-03-2014, 04:25 PM,
#2
RE: tan, sin, cos, atan..... Funcionan en pinguino?
Hello,

(24-03-2014, 03:43 PM)kmiz07 Wrote: I have not been able to find information about which of these functions are supported by penguin.

Pinguino lacks a little bit of documentation...

(24-03-2014, 03:43 PM)kmiz07 Wrote: Specifically I would be interested sin (), cos () and atan (). (arctangent)
Besides, I have not managed to find an updated place to see ansiC functions are supported or not.

I've found these trigonometric functions in the source code. They are availabe for both 8 bit PICs and PIC32MX. At the moment sin and cos functions are defined.

Oliver
Reply
24-03-2014, 06:18 PM,
#3
RE: tan, sin, cos, atan..... Funcionan en pinguino?
Hello,

In complement that Oliver said, i suggest to look at :
http://stackoverflow.com/questions/11930...ons-or-c99

you can find implementations of Atan functions in c, but need to be adapted to sdcc/pic.

Thomas
Reply
24-03-2014, 09:47 PM, (This post was last modified: 24-03-2014, 09:56 PM by pinguPlus.)
#4
RE: tan, sin, cos, atan..... Funcionan en pinguino?
(24-03-2014, 06:18 PM)Callmea Wrote: you can find implementations of Atan functions in c, but need to be adapted to sdcc/pic.

Some more links for the guys, who wants to bring us a math library Smile
The Espruino project has an interesting math lib written in C. I have no idea of how much effort this would be to port to sdc (or gcc for pic32).
Maybe one of the experienced programmers being here around could take a look and drop a comment.

Just an idea Smile

Oliver

Edit 24.03.2014 20:55h: All the Espruino source files are licensed under Mozilla Public License Version 2.0
Reply
25-03-2014, 09:25 AM,
#5
RE: tan, sin, cos, atan..... Funcionan en pinguino?
Hi

All these function are already implemented in PIC32 board, I do not know for other boards.

The program
Code:
void setup()
{
}

void loop()
{

double  Vas,Vas1,Vad;
char Str[30];

Vas = 1.234;
Vad = sin(Vas);
sprintf(Str,"sin %f = %f\r\n",Vas,Vad);
CDC.printf(Str);  

Vad = cos(Vas);
sprintf(Str,"cos %f = %f\r\n",Vas,Vad);
CDC.printf(Str);  

Vad = tan(Vas);
sprintf(Str,"tan %f = %f\r\n",Vas,Vad);
CDC.printf(Str);  

Vas = 0.987;
Vad = asin(Vas);
sprintf(Str,"asin %f = %f\r\n",Vas,Vad);
CDC.printf(Str);  

Vad = acos(Vas);
sprintf(Str,"acos %f = %f\r\n",Vas,Vad);
CDC.printf(Str);  

Vad = atan(Vas);
sprintf(Str,"atan %f = %f\r\n",Vas,Vad);
CDC.printf(Str);  

Vas = 0.987;
Vad = sinh(Vas);
sprintf(Str,"sinh %f = %f\r\n",Vas,Vad);
CDC.printf(Str);  

Vad = cosh(Vas);
sprintf(Str,"cosh %f = %f\r\n",Vas,Vad);
CDC.printf(Str);  

Vad = tanh(Vas);
sprintf(Str,"tanh %f = %f\r\n",Vas,Vad);
CDC.printf(Str);  

Vas = 8;
Vad = asinh(Vas);
sprintf(Str,"asinh %f = %f\r\n",Vas,Vad);
CDC.printf(Str);  

Vad = acosh(Vas);
sprintf(Str,"acosh %f = %f\r\n",Vas,Vad);
CDC.printf(Str);  

Vas = 0.987;
Vad = atanh(Vas);
sprintf(Str,"atanh %f = %f\r\n",Vas,Vad);
CDC.printf(Str);  

Vas = 1.456;
Vas1 = 0.567;
Vad = atan2(Vas,Vas1);
sprintf(Str,"atan2 %f ---- %f",Vas,Vas1);
CDC.printf(Str);  
sprintf(Str," = %f\r\n",Vad);
CDC.printf(Str);  

delay(3000);
}

Work fine on PINGUINO32-MICRO

Code:
sin 1.234000 = 0.943818
cos 1.234000 = 0.330465
tan 1.234000 = 2.856030
asin 0.987000 = 1.409376
acos 0.987000 = 0.161420
atan 0.987000 = 0.778856
sinh 0.987000 = 1.155240
cosh 0.987000 = 1.527933
tanh 0.987000 = 0.756080
asinh 8.000000 = 2.776472
acosh 8.000000 = 2.768659
atanh 0.987000 = 2.514716
atan2 1.456000 ---- 0.567000 = 1.199441

Only main function (sin, cos, tan) are available in pdl but this is not a problem.


Bye Bye, Moreno
Reply
25-03-2014, 09:56 AM,
#6
RE: tan, sin, cos, atan..... Funcionan en pinguino?
They must be provided by libm.a and math.h part of GCC. The make file has "-msoft-float" and "-lm" flags.

Too bad, the "%f" is very poorly implemented and it is best to avoid using.

DJ
Reply
26-03-2014, 09:22 PM,
#7
RE: tan, sin, cos, atan..... Funcionan en pinguino?
Functions powf, sqrtf, absf, sinf, cosf and tanf (as usual no needs to include <math.h>, the IDE will do it for you) are implemented for 8-bit boards.
sinf, cosf and tanf have also an optimized version (sinr, cosr and tanr) I will publish soon.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
30-03-2014, 02:09 AM,
#8
RE: tan, sin, cos, atan..... Funcionan en pinguino?
Muchas gracias, Me lie un poco con el uso de radianes pero ya voy en marcha con las funciones trigonometricas.

Thank you very much, I lie a little using radians but I'm coming up with trigonometric functions.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)