View Full Version : Moving Buttons
Beaver08
10th February 2012, 22:21
Hey guys i'm hoping you could help me,
i was wondering what math does it take exactly to show a button as if it's static on the track but have it move across your screen accordingly to your heading
i was told it could be trigonometry but i can't find anything that really helps out and i'm not exactly brilliant at maths.
if anybody could help me out with, figuring out which values i need to get and compare them etc, I would greatly appreciate it.
MadCatX
10th February 2012, 22:36
It depends on the level of accuracy. Giving a button a fixed position in 3D space and determining if and where it should be displayed involves some vector algebra and trigonometry. I don't know what calculations exactly you'd have to do off the top of my head, but I reckon it could be reasonably easy.
Beaver08
11th February 2012, 16:33
well any step to get me onto the right direction would be greatly appreciated..
if somebody could lay out the math i need to do or what values etc i need to get and set it would help me alot as i feel like i'm trying to find a needle in a haystack in the dark lol
EDIT: the values doesnt need to be 100% accurate but atleast close
stan.distortion
11th February 2012, 17:33
What your looking for is vector mathematics using Euclidean geometry. Hard enough to pronounce and a lot of work to set up from simple mathematics but fairly simple once there are procedures set up to do all the work. Fortunately there are lots of libraries already set up to handle this kind of thing, not sure which is the best to suggest for your needs though.
MadCatX
11th February 2012, 18:58
Thinking only in 2D and assuming that you want to project a position of an object on the windscreen (a sort of a HUD if you will), what you need to do is something like this. (the green line is the windscreen width, the "+" is the object's real position and the diamond is where the object has to be projected). I didn't have time to fire up LaTeX and GNUPlot, so my terrible handwriting will have to do for this time (sorry).
Beaver08
11th February 2012, 19:10
i appreciate the picture you have given but would you be able to write the text here, as i find that quite difficult to read :P
Thanks again.
EDIT i can read most within the chart just want to know your what your equations at the bottom say :P
MadCatX
11th February 2012, 19:16
From the top:
r0: y = kx + q
y = tg(beta)x + q
q = - distance from camera (DFC)
x = DFC / tg(beta) (windscreen is on the X-axis, so Y is 0).
I hope you get where I was going with this. I suppose it should work as long as you're working only with points in 2D space. (You could do the same for height to move the button up and down on the windscreen)
Beaver08
11th February 2012, 21:02
ok i've been staring at this for a while and still can't figure it out, i must be stupid
would you be able to rename the values so i can get a better understand to
Car.X
Car.Y
for the players pos
PosX
PosY
for the point and then
H for heading, i assume that's the values you've told me to use here. if not i'm just dumb :P
just to make it a little simpler for me. as i dont even get where or wat r0 is and if you could could you explain the math equations coz i dont get what you mean by (beta) thanks.
Beaver08
19th March 2012, 13:56
Ok i'm getting desperate i'm willing to offer atleast £5gbp paypal money for somebody who can lay out this equation for me in C# and have it working atleast to a stage where i can finish it
as i explained before i suck at maths and really want this figured out.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.