Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright

sin and cos in dsp and green?

For general discussion related FlowStone

sin and cos in dsp and green?

Postby Nubeat7 » Wed Jun 17, 2015 7:26 pm

hello

could someone please describe the difference between the sin primitive in green and the sin1(x) funtion in dsp code?

the description in the user guide is also fucked up :

sin1(a)
cos1(a)
tan1(a)
Mathematical sine, cosine and tangent
The 1 indicates that the input value a is converted to a value in the range 0-1
and not 0 and 2 . So 0.5 would be equivalent to  and 1.25 would be
equivalent to  /2


what a shame :?
edit: my reader doesn't show this right!

i try to translate some codes from dsp into green which includes sin and cos functions and i'm not able to do this?
Last edited by Nubeat7 on Wed Jun 17, 2015 8:11 pm, edited 1 time in total.
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: sin and cos in dsp and green?

Postby tulamide » Wed Jun 17, 2015 7:52 pm

In general, sine and cosine are circle functions, therefore used with values in radians. pi is half a circle, 2pi a full circle (degree equivalent: 180° and 360°)

But instead of radians or degree, sin1 expects a value range of 0-1, so that 1 refers to 360° = 2pi = full circle (in case of the sine function that means one full loop - the laying S )

And so for the other functions as well. In visuals, degree or radians make a lot of sense, in audio not at all. 0-1 makes a lot more sense there.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: sin and cos in dsp and green?

Postby Nubeat7 » Wed Jun 17, 2015 8:09 pm

thanks tulamide, so the "fucked up sign " ín the userguide should be Pi, for some reason my adobe reader is showing it wrong ..

now its clear, i need to multiply the green sin/ cos inputs with 2pi when translating from dsp code.
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna

Re: sin and cos in dsp and green?

Postby tulamide » Wed Jun 17, 2015 8:15 pm

Nubeat7 wrote:now its clear, i need to multiply the green sin/ cos inputs with 2pi when translating from dsp code.

Are you sure? Maybe I don't understand you correctly, but if you want to make a green "sin1" function, you only need to divide the incoming value by 2pi. Or if you have a signal range of 0-1 that you want to feed green with (using the sin etc prims, then it's indeed multiplying with 2pi.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: sin and cos in dsp and green?

Postby KG_is_back » Wed Jun 17, 2015 8:38 pm

Basically trigonometric functions expect an angle (expressed as a number) and return the ratio of different sides of right triangle. While ratio is a pretty solid concept, angle isn't. There are plenty of ways to express angle as a number.

Most common ones are:
1. radians - 2pi radians = full rotation. Radian is the most natural and is derived from a distance travelled along circle. You travelled one radian, when you travelled a distance along a circle equal to its radius. That turns out to be very important in physics.
2. degrees - 360 degrees = full rotation. Degree is an approximation of angle the sun travels along a (night) sky each day, thus popular in astronomy, naval navigation and geodesy. Also 360 is divisible by 2,3,4,5,6,8,9,10,12,15,18,20,... Making it very easy to express common angles in whole numbers. Degrees are base 60 - 1/60th of a degree is minute, 1/360th is a second.
3. turns - 1 turn=full rotation. Very useful in DSP, because 1 turn/second = 1Hz. And it's also pretty straightforward, when you're talking about rotation / periodic events.
4. hours - 24hours = full rotation. Popular in astronomy, because you can easily express relative position of stars based on time it takes for them to noon. Again base 60 is used for minutes and seconds.
5. grade of slope. Works only in 1st quadrant ( =for angles smaller than right angle). It is a ratio between vertical and horizontal distance (how high you go relative to how far you go). It is usually expressed in percent and it is often used on traffic signs. grade of 1% means for every 1m you travel horizontally, you travel 1cm vertically. Grade of slope = tan(angle).

sin(x) usually accepts the angle in radians, but sometimes in degrees (on most pocket calculators).
sin1(x) accepts angle in turns.
Code: Select all
sin1(x)=sin(x*2pi) <=> sin(x) = sin1(x/2pi)
KG_is_back
 
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: sin and cos in dsp and green?

Postby tulamide » Wed Jun 17, 2015 8:49 pm

KG's post above == my posts combined in more precise and better looking 8-)

I'm afraid you're also better-looking in real life, too :lol:
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: sin and cos in dsp and green?

Postby Nubeat7 » Wed Jun 17, 2015 9:39 pm

tulamide wrote:
Nubeat7 wrote:now its clear, i need to multiply the green sin/ cos inputs with 2pi when translating from dsp code.

Are you sure? Maybe I don't understand you correctly, but if you want to make a green "sin1" function, you only need to divide the incoming value by 2pi. Or if you have a signal range of 0-1 that you want to feed green with (using the sin etc prims, then it's indeed multiplying with 2pi.


yes maybe i wasn't articulating clear enough, i want to translate from dsp code into green ( or to be more precise i did it into ruby where the input of the sin/cos functions are also radians) so i need to scale the 0..1 range to radians which is *2pi

@KG thanks for the detailed explanation :)
User avatar
Nubeat7
 
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna


Return to General

Who is online

Users browsing this forum: Google [Bot] and 40 guests