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.

Dark GDK .NET / Math Formula

Author
Message
Huntinator
14
Years of Service
User Offline
Joined: 21st Dec 2009
Location: Channel 57
Posted: 17th Apr 2010 19:06
Hey I've started a new project which requires me to be able to move an object based on its angles and distance it needs to move, something similar to the Move Command(Which I can't use in this project.). I was wondering if anyone knows how to do that? I'm pretty sure you use Sine, Cosine, and tangent but i'm not sure how.
veltro
User Banned
Posted: 19th Apr 2010 10:43
Starting point x0,y0
Distance D
Angle A

Target point

x1 = x0 + D * cos(A)
y1 = y0 + D * sin(A)
Huntinator
14
Years of Service
User Offline
Joined: 21st Dec 2009
Location: Channel 57
Posted: 24th Apr 2010 00:33
What about the z-axis?
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 24th Apr 2010 01:18
Quote: "(Which I can't use in this project) "


Why not?
Going into the third dimension may throw up a world of trouble, matrices, quaternions etc.., sorry I can't help.

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 24th Apr 2010 12:51
A simple "orbit" calculation would be

X = centerX + radius*cos(angleY)*cos(angleX)
Y = centerY + radius*sin(angleX)
Z = centerZ + radius*sin(angleY)*cos(angleX)

where
(centerX, centerY, centerZ) is the starting point
radius is the distance
(angleX, angleY) are the angles that will determine the position on the sphere.

They are called sphere coördinates (you can wiki it for more information), though they'll probably use the starting point as the origin.

Cheers!
Sven B

Huntinator
14
Years of Service
User Offline
Joined: 21st Dec 2009
Location: Channel 57
Posted: 25th Apr 2010 06:37
Thanks it worked perfedtly.

Login to post a reply

Server time is: 2024-04-24 12:58:22
Your offset time is: 2024-04-24 12:58:22