Jump to content


- - - - -

vector maths


1 reply to this topic

#1 rajesh kumar

    Member

  • Members
  • PipPip
  • 30 posts

Posted 29 June 2009 - 12:22 PM

Hi to all,
Can anyone help me fix this problem.
i am working on collision avoidance for ai vehicle .For that i have to know future position of my aivehicle in a x,z plane. y axis is for rotation only.

Example:
myaicar position & rotation is

position = "200.081 1 -612.843 ";
rotation = "0 1 0 87.0896"; //87.0896 is angle
//x axis rotation is 0
//y axis rotation is 1
//z axis rotation is 0
myaicar target position is
//this is the path my aicar travelling
path1 = "400 -612.843 1";
path2 = "400 -900.784 1";
path3 = "200 -900.784 1";
path4 = "200 -612.843 1";

i tried it
float speed = 10;
D3DXMATRIX rot;
D3DXVECTOR3 vecf(1,0,0);
D3DXVECTOR3 speedvector;
float X_POSITION =200.081f,Y_POSITION = 1, Z_POSITION =-612.843f;
D3DXMatrixRotationY(&rot,87.0896f);
D3DXVec3TransformNormal(&vecf,&vecf,&rot);
speedvector=vecf*speed;
X_POSITION+=speedvector.x;
Z_POSITION+=speedvector.z;

cout<<X_POSITION<<endl<<Y_POSITION<<endl<<Z_POSITION;

result is fine
206.491
1
-605.168

but i tried to path3 from path2 rotation in y axis rotation is 182.201
result is

410.08
1
-900.729

but i wanted a result like this
400
1
-910


Please someone guide me achieve this

Thanks in advance


---Rajesh---

#2 rajesh kumar

    Member

  • Members
  • PipPip
  • 30 posts

Posted 01 July 2009 - 06:01 AM

i solved the above issue .Thank you for the guys tried to help me





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users