Simple Question - TGB
by Justin Proffitt · in Game Design and Creative Issues · 07/08/2009 (3:45 pm) · 3 replies
I am having trouble thinking today, and I am still some what new to Torque (had it a few months). I am certain that I encountered a tutorial which provided one line of code which will calculate the angle from point a to point b, without having to do any conversions because of Torque's way of using degrees (0 at top progressing clockwise; range from -359 to 359). So, given I have provided enough information, how can I do this in one line/statement? Or is it technically impossible without doing some conversion somewhere?
Edit: No longer so simple.
Edit: No longer so simple.
About the author
I am a college student majoring in physics. As it so happens I like programming, a hobby which extends my profession in web design.
#2
Edit: fixed, tackling syntax issues now but that is all.
07/08/2009 (6:54 pm)
In theory your code works, thank you :)Edit: fixed, tackling syntax issues now but that is all.
#3
Edit: This gets its own thread.
07/09/2009 (8:35 am)
Well I am on to a different problem, how can you return two values from one function, like getPosition() does, in torquescript?Edit: This gets its own thread.
Torque Owner Tyler Slabinski
function convertAngle() { %xSlope = (%bX - %eX); %ySlope = (%bY - %eY); %angle = ((mRadToDeg(mAtan(%xSlope, %ySlope)) + 90) * -1) + 180; //Get the arctan of the slopes. Then convert it to degrees.}%bX and %bY are the beginning points of what you want the angle to be. The X and Y positions of them.
%eX and %eY are the ending points of what you want the angle to be.
Then it does math to get the arc tangeant of the slopes. Does a few mathematics, and then puts it into degrees form.