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 Professional Discussion / How to rotate 2d vector?

Author
Message
CuCuMBeR
22
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 12th May 2005 07:29
vec = make vector2(vector)
set vector2 vector, 1,0

do
if leftkey() > 0
angle = angle - 1
endif
if rightkey() > 0
angle = angle + 1
endif

rotate vector2 vector, angle ?? --> how do i do that?
loop
CuCuMBeR
22
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 12th May 2005 17:20
anybody?
Raven
20
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 12th May 2005 19:21
huh?
erm... a vector2 is just 2 floating point values, it isn't an object.

Given in a 2D Space (x,y) you only really have a single rotation angle, and this is done around the depth (z) axis.. it isn't a real axis as far as 2D Space is conserned so call it a Theoretical Z.

Well anyways.. all you want is to make a Vector3(x,y,z)

INT(X) = Screen X (in pixels)
INT(Y) = Screen Y (in pixels)
WRAPVALUE(Z) = Rotation Angle

Still how you use this information is up to you, buggered if i'm showing you how to use SohCahToa to bloody calculate the rotational difference.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th May 2005 20:15
If you calculate the distance, then the angle, you can adjust the angle and calculate the new position with simple sin and cos math.

So you need to know how to work out the distance between 2 points, and the angle between 2 points (atanfull command) - from that you can work out the results quite easily.


Van-B

CuCuMBeR
22
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 12th May 2005 22:15
i was trying to ask somethin else, nevermind

Login to post a reply

Server time is: 2025-06-02 14:04:00
Your offset time is: 2025-06-02 14:04:00