general coding question (extreme maths)

Author Topic: general coding question (extreme maths)  (Read 1629 times)

okay so this isn't for a project in TS, so any direct TS implementations aren't going to help me, however help is still very appreciated.

In my application I have two objects operating on a 2d environment.

Each object has an x,y coordinate, and I need to know how to point object 1 to object 2 using those x,y coordinates. This has to be done using degrees to rotate the object or radians (which i have no idea what they are or how to use them)

Do you specify the rotations in degrees or radians??

Do you specify the rotations in degrees or radians??
either or, doesn't matter

1) Add both x-values (negatives are important) of the two points to create "Rx"; do the same for "Ry".

2) arctan(Ry/Rx) is the angle; correct result for proper quadrant

If Rx is zero, the angle is either 90 degrees or 270 degrees. FYI, Torque has an arctangent function that automatically corrects the angle for the quadrant.

1) Add both x-values (negatives are important) of the two points to create "Rx"; do the same for "Ry".

2) arctan(Ry/Rx) is the angle; correct result for proper quadrant

If Rx is zero, the angle is either 90 degrees or 270 degrees. FYI, Torque has an arctangent function that automatically corrects the angle for the quadrant.
forget i knew it

i was using tanh instead of atan

forget i knew it

i was using tanh instead of atan
tanh is hyperbolic tangent and I have no loving clue what it does.

tanh is hyperbolic tangent and I have no loving clue what it does.
neither do i dont feel too bad

Turning an object on a two-dimensional plane to face another object is simple.

Code: [Select]
function turnTo(%obj, %targ)
{
   %pos = %obj.getPosition();
   %diff = vectorSub(%targ.getPosition(), %pos);
   %ang = mAtan(getWord(%diff, 0), getWord(%diff, 1));
   %obj.setTransform(%pos@" 0 0 1 "@%ang);
}

so i attempted to reverse it, sort of

trying to get the x,y coordinates of an object using the angle from the other object to that object.

basically i really forgeted up

i tried to sine and cosine of the angle which from what i've seen should retrieve the x,y but they always return 0,0