Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / math problems

Author
Message
Takeshii
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location:
Posted: 30th Apr 2006 14:51
Well, I'm not the best at math, but im always willing to learn. My problem is that I have a line, with the two ordered pairs stored into 4 different variables (ax, ay, bx, by) and i need to apply a angle to that line, say 30 degrees, and keep the distance the same. Either this is too simple for me to see, or to complex for me.

Dark
TDK I Love you...... And yes, you should be scared
<Img Scr="http://mysite.verizon.net/grueslayer/PNABJL.png"></img>
Xander
22
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 1st May 2006 00:44 Edited at: 1st May 2006 00:46
-Find the starting angle and distance of the line

angle=atanfull(ay-by,ax-bx)
distance=sqrt((ax-bx)^2+(ay-by)^2)

-Add 30 degrees to it

angle=wrapvalue(angle+30)

-Find new points

bx=cos(angle)*distance+ax
by=sin(angle)*distance+ay

That should do it

[edit] fixed a big stupid mistake...

Xander Moser - Bolt Software - Firewall
Takeshii
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location:
Posted: 1st May 2006 06:53
That is exactly what I was looking for, thank you very much!

Dark
TDK I Love you...... And yes, you should be scared
<Img Scr="http://mysite.verizon.net/grueslayer/PNABJL.png"></img>
Xander
22
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 1st May 2006 08:38
No problem, glad you understood basic trig

Xander Moser - Bolt Software - Firewall

Login to post a reply

Server time is: 2025-05-23 15:32:21
Your offset time is: 2025-05-23 15:32:21