Finding Degree/Radian value of sine wave

Appyro

New member
Joined
Aug 27, 2019
Messages
6
Hello Everyone,

I'm having some problems with a bit of trig based maths code I'm am trying to write for a game, The problem is this:

I have an object that is moving in 2d space along the y-axis using a sin wave function.
At any time, given the current amplitude and frequency, I want to be able to get the degree/radian value for a given y-axis value so I can jump the object to a different point in phase on the same sinewave as a sort of 'teleport'. Importantly I want to be able to teleport to a y-axis value within that wave by deriving the degree point.

for example:
In a sine wave of amplitude = 'A', and frequency = 'F',
What position/s on the wave in degrees (or radians) does the y-axis value 'Y' appear

or worded differently:
using, amplitude = 'A', frequency = 'F' and y-axis position = 'Y', determine the degree's/Radian values that 'Y' can appear

It is my understanding that in most situations there are 2 points for each y-axis value on the wave (except the peak and trough that would have only 1 value)
I would like to know if there is a way to get specifically the point on an incline or decline on the wave
aka, a point between 0 to <90 or >270 to 360 (the rising parts of the wave) or a point between 90 to 270 (the falling part of the wave)

Any help would be greatly appreciated,
Thanks!
 
This might be helpful:
 
thank you for the link tho I don't fully understand what they are talking about here, I see this equation that I think they are saying can be used to find these equivalent angles => tan(x) = tan(x+n*pi)
though I don't understand what x and n represent, or how I would derive the first degree to then find its equivalent angles.
 
As I wrote in that thread: For any periodic function f(x) = f(x+n*period).
So, sin(x) = ?
I'm assuming your function is Asin(Fx). What is its period?
In addition to adding n*period we can get points of equal value by observing that sin is symmetrical. This is where OP's equalities in the linked thread come from.
 
Ok so I think I'm starting to understand, Very new to this whole area of maths...

So let say I have a position on the wave, 75 degrees, I could convert this to a radian = 75 x pi/180 = 1.309 radians

and I could use this value to determine another radian position of equal y-axis value (=> when plotted, sorry this is how I'm visualizing it)
with this equation:

Equal value position in radians = tan(1.309 + n * pi) ???

I still don't understand what the N means, what value I would look to pass into n if this is correct?
If not what steps have I missed?

I'm also not sure if this only solves one part of my problem as I would also like to add a step before this where I figure out the first raidan value from the y-axis plot position, though I'm starting to think this is not possible as there would be 2 potential answers?

Thank you again so much for your time!
 
Hello Everyone,

I'm having some problems with a bit of trig based maths code I'm am trying to write for a game, The problem is this:

I have an object that is moving in 2d space along the y-axis using a sin wave function.
At any time, given the current amplitude and frequency, I want to be able to get the degree/radian value for a given y-axis value so I can jump the object to a different point in phase on the same sinewave as a sort of 'teleport'. Importantly I want to be able to teleport to a y-axis value within that wave by deriving the degree point.

for example:
In a sine wave of amplitude = 'A', and frequency = 'F',
What position/s on the wave in degrees (or radians) does the y-axis value 'Y' appear

or worded differently:
using, amplitude = 'A', frequency = 'F' and y-axis position = 'Y', determine the degree's/Radian values that 'Y' can appear

It is my understanding that in most situations there are 2 points for each y-axis value on the wave (except the peak and trough that would have only 1 value)
I would like to know if there is a way to get specifically the point on an incline or decline on the wave
aka, a point between 0 to <90 or >270 to 360 (the rising parts of the wave) or a point between 90 to 270 (the falling part of the wave)

Any help would be greatly appreciated,
Thanks!
I am not sure I understand what you are even talking about. It would help if you were to give the actual function that you are working with.

For example, you talk about the "degree point." Degrees are not points. Are you talking about the numeric value of the angle in degrees between the x-axis and a line drawn from the origin to the point (x, y)?

Because I have only a fuzzy idea what you are trying to say, I may be giving you irrelevant or even bad information. Nevertheless, it appears that part of what you want (except at the origin) is given by

[MATH]arctan \left ( \dfrac{y}{x} \right ).[/MATH]
This will give you the principal value, [MATH]-\ \dfrac{\pi}{2} < \text {principal value} < \dfrac{\pi}{2}.[/MATH]
Now I am not aware of the teleport function. What specifically do you want to do (in the language of mathematics rather than science fiction) once you have calculated the value of the relevant angle?
 
I am not sure I understand what you are even talking about. It would help if you were to give the actual function that you are working with.

For example, you talk about the "degree point." Degrees are not points. Are you talking about the numeric value of the angle in degrees between the x-axis and a line drawn from the origin to the point (x, y)?

Because I have only a fuzzy idea what you are trying to say, I may be giving you irrelevant or even bad information. Nevertheless, it appears that part of what you want (except at the origin) is given by

[MATH]arctan \left ( \dfrac{y}{x} \right ).[/MATH]
This will give you the principal value, [MATH]-\ \dfrac{\pi}{2} < \text {principal value} < \dfrac{\pi}{2}.[/MATH]
Now I am not aware of the teleport function. What specifically do you want to do (in the language of mathematics rather than science fiction) once you have calculated the value of the relevant angle?

Thank you for your feedback Jeff, as you can tell I'm not a great mathematician but will try to explain it better,

Let's ignore the teleport thing, for now, I'm still quite confused about that myself...

My Maths:

I am generating sine wave movement on a y-axis over time in 2D space using the y(x) = sin(x) formula passing in radian values converted from degrees.
Taking the value returned (a value between -1 and 1) I multiply that by an 'amplitude' value to achieve my y-axis position for the object.

So for anyone instance of the equation, I would say:
where:
Y = y-axis plot position
A = amplitude
X = radian value

Y = Asin(X)
Y = A multiplied by sin(X) - (in case it's not clear, I'm unsure of the standard math notation coming from programming only)

I'm really sorry if this is bad math notation =(

So to tie that in,
I know the degree in the cycle of the sine wave I am at (in terms of its x-axis when plotted on a graph)
From this, I can derive what y-position I should use as explained above.

I believe this y-axis value when looking at a graph would appear two times, for example, 80 degrees along the x-axis and 100 degrees
along the x-axis would share the same y-axis value in a plotted sine wave graph.

It is this other x value that shares a y value that I am after.

I really hope this makes it clearer, thank you for bearing with me!
 
Ok so I think I'm starting to understand, Very new to this whole area of maths...

So let say I have a position on the wave, 75 degrees, I could convert this to a radian = 75 x pi/180 = 1.309 radians

and I could use this value to determine another radian position of equal y-axis value (=> when plotted, sorry this is how I'm visualizing it)
with this equation:

Equal value position in radians = tan(1.309 + n * pi) ???

I still don't understand what the N means, what value I would look to pass into n if this is correct?
If not what steps have I missed?

I'm also not sure if this only solves one part of my problem as I would also like to add a step before this where I figure out the first raidan value from the y-axis plot position, though I'm starting to think this is not possible as there would be 2 potential answers?

Thank you again so much for your time!
You need sin, not tan. N is the number of periods. Let's say you are at the top of the sin(x) wave. To jump to the next top on the right you need to add one period to x. You can add as many periods as you want to jump to any top.
 
You need sin, not tan. N is the number of periods. Let's say you are at the top of the sin(x) wave. To jump to the next top on the right you need to add one period to x. You can add as many periods as you want to jump to any top.

Ahh! this is very helpful! Thank you.

so with this, passing in the value of 1 for periods, I could effectively jump 1 full cycle from the given x radian value.
I can see also then how I could jump any number of degrees forward, for example by setting n to 0.25 I could jump 90 degrees forward?

The other part of the dilemma is how to know what value to pass in for periods in order to jump to the point on the wave I am trying to reach.

This diagram I hope shows the relation between my current X value and my desired X value

WaveDilema.png

Thank you again for helping me out!
 
If the point on the left is at x, its distance from 0 is x. The point on the right is x distance from 180 because of symmetry. So what would be its coordinate?
 
If the point on the left is at x, its distance from 0 is x. The point on the right is x distance from 180 because of symmetry. So what would be its coordinate?

Ahh this is the most satisfying sentence I have read all day! feels like the final piece to the puzzle.

so if I'm at x value of 135 and I want another coordinate on the wave with the same y-axis value,
180-135 = 45 = desired x value
aka (45, n) and (135, n) are both coordinates on the wave and share the value of n?

or if I'm at x value of 190 say, it would be 10 from 180 so the x I want is 350 as that's 10 from 360! (working in the negative y values)

I think this all makes sense to me unless what I've said here is totally wrong! =o

Thank you so much for helping me understand this process step by step!
 
Top