jamesN616 wrote ...

2018/5/16

# Trig problems

jamesN616

2018/5/16

I want an actor to be able to reference specific points within its image; i.e., front, back, sides. The problem is that the actor is able to rotate, so I can't just create a permanent offset from the actor's center. I need to be able to calculate the x and y distances that the reference point is offset from the actor's center as it rotates. I need to essentially create a fixed point on the actor without moving that point by rotating the actor. My process so far has been trying to convert a rotation into x and y integers that form a triangle with the given angle, without exceeding the height/width of the actor With trig, I can use an x and y offset to create a rotation, but I need to essentially reverse that process. I need to get an x and y position from a given angle of rotation, but am unsure as to how I can do that. I can't use getNeighbors(), or getObjectsAtOffset(), or similar methods that find an object offset from the actor because the actor is finding different color patterns in the world, as opposed to finding different objects. Any suggestions are appreciated
jamesN616

2018/5/16

Embarrassed to admit that the answer was much simpler than I thought, but I figured it out. If anyone runs into a similar problem; Offset X = (initial length of X at no rotation) * cos(angle rotated) Offset Y = (initial length of X at no rotation) * sin(angle rotated) And swapping X and Y, or making values negative can find offset positions at different points
Ticker175

2018/5/17

A^2+b^2=c^2 c= hypot a,b=other angles
jamesN616

2018/5/17

Ticker175 wrote...
A^2+b^2=c^2 c= hypot a,b=other angles
I don't think that the pythagorean theorem isn't the best for this problem, as the position of the point on the object is dependent on the object's rotation, but maybe you can see it differently? That is, I don't think it's possible to find A without knowing B or vice versa, which is difficult as B and A change while the angle does. And even then, calculating A or B off of the angle would just reduce mathematically to what I have already, with the cos and sin relationships. I appreciate the suggestion, but am unsure on how to use it.