Working out a position with just X,Y,Z
#1

Hi, I need a function for it to work out the position of the checkpoint exit position look in the image below:



The brown line = Wall
Blue dot = CP
Red X = Where I want the exit pos to be.

If I have the x,y,z of the CP can I find out the x,y,z of the red X?

Kyle

Thanks!
Reply
#2

does your checkpoint data include an angle for the checkpoint? providing one, you can calculate the exit point with the sinus/cosinus functions. with the walls orientation, the angle of the checkpoint could be calculated aswell.
presuming your checkpoint coordinates are cX,cY,cZ,cA, and Radius is like 5 units, this should give you some results:
Код:
new cXNew=Radius*floatsin(cA+180,degrees);
new cYNew=Radius*floatcos(cA+180,degrees);
you noticed the 180 - in your example the wall is at north, thats 0 degrees. rotate (sour skin) 180 degrees, then you watch away from that wall. step forward 5 units, then you got back to your desired position. the same trick will work on any wall rotation, just think about a 90 degrees rotated wall: the sinus will be 0, where the cosinus is 1. the cosinus axis result adds the radius (5) multiplied with the bias (cosinus value=1) == 5 to the left (90 plus 180= 270, thats the left side)

i typed this out of my mind, w/o checking...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)