Solve for x or y with a given angle

Beaty

New member
Joined
Aug 14, 2018
Messages
3
It's been over 20 years since I've had to do trig, so forgive me if this seems like a complete 101 question.

I need two single formulas that will swap the x,y depending on quadrant. The solution will be Px or Py. The angles are simple, 0,90,180,-90 (software won't take 270) provided by the user.

Px and Py are provided from a table (for instance Px=0.4A, Py=18B).

First formula (X position):
If theta = 0, X = Px; if theta = 90, X = Py; if theta = 180 X = -Px; if theta = -90, X = -Py
Second formula (Y position):
If theta = 0, Y = Py; if theta = 90, Y = Px; if theta = 180, Y = -Py; if theta = -90, Y = -Px
Thanks in advance
 
… need two single formulas that will swap the x,y depending on quadrant. The solution will be Px or Py. The angles are simple, 0,90,180,-90 (software won't take 270) provided by the user …
No need for concern asking for help at a help site. :cool:

None of those four angles are in any quadrant. For each, the terminal ray of the angle lies on an axis. (The x-axis and y-axis are not part of any quadrant.)

You say the "solution" will be Px or Py, but I see you're also using -Px and -Py.

Are you writing a computer program? If so, is there a reason not to use cases? (There's only four possibilities for each variable X and Y.)
 
Last edited:
It's been over 20 years since I've had to do trig, so forgive me if this seems like a complete 101 question.

I need two single formulas that will swap the x,y depending on quadrant. The solution will be Px or Py. The angles are simple, 0,90,180,-90 (software won't take 270) provided by the user.

Px and Py are provided from a table (for instance Px=0.4A, Py=18B).

First formula (X position):
If theta = 0, X = Px; if theta = 90, X = Py; if theta = 180 X = -Px; if theta = -90, X = -Py
Second formula (Y position):
If theta = 0, Y = Py; if theta = 90, Y = Px; if theta = 180, Y = -Py; if theta = -90, Y = -Px
Thanks in advance

Can you explain more about why you are doing this? I don't understand where A and B fit in; and if you changed some signs, you would be rotating by angle theta, but as it stands, you are doing something unrelated to the angle! If you change this to a rotation, it can be done by a single formula (though using it for only those four angles might be a little overkill).
 
I'm building catalog components for a 3d piping software.

I want to rotate the origin of a vector/pointer on the x/y plane around the z axis. The only practical angles give by the user will be 0, 90, 180 & -90.
 

Attachments

  • screen shot.jpg
    screen shot.jpg
    50.2 KB · Views: 2
I'm building catalog components for a 3d piping software.

I want to rotate the origin of a vector/pointer on the x/y plane around the z axis. The only practical angles give by the user will be 0, 90, 180 & -90.

Okay, you really are rotating, so you did have wrong signs (which should not be the same when you rotate 90 degrees).

It appears that the point you are rotating is (Px, Py), which is somehow derived from some input (A, B); I can't tell what you meant by "Px=0.4A, Py=18B", but that appears to be irrelevant to the question.

When you rotate (Px, Py) by an angle θ, the result is the point (Pxcosθ - Pysinθ, Pxsinθ + Pycosθ). For example, if θ = 90°, we get (Pxcos90° - Pysin90°, Pxsin90° + Pycos90°) = (Px*0 - Py*1, Px*1 + Py*0) = (-Py, Px).
 
That did the trick. For 1 case, ended up with:

X=( 0.4 * PARA[2 ] * SIN ( ANGL ) + PARA[6 ] * COS ( ANGL ) )
Y=( 0.4 * PARA[2 ] * COS ( ANGL ) - PARA[6 ] * SIN ( ANGL ) )

Thanks for the help.
 
Top