Jump to content

RotateVector? (Tformvector?)


Andy Gilbert
 Share

Recommended Posts

Hi, im having a few issues regarding some physics and in talks with Somone who is helping me out, he is suggesting that in order to achive the result i need to Rotate the vector with the body matrix?

 

P = RotateVector (vehicle matrix, CP) <-- no LE command (its what he suggested)

 

After playing around more and having no luck I questioning it again and it was advised again that its because i am transforming the vector and not rotating it. And suggested i do somthing like this:

 

pg = TransformVector (bodyMatrix, p)

 

Anyone know what he means by rotate the vector with the bodymatix?

 

Is this somthing i can do using TFormVector?

 

Sorry if this all sounds a bit wishy washy.

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Maybe it would be better to explain what the actual problem is, usually LE2 has already the commands built-in, and there is no need to math.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Im trying to calculate the velocity at a point on a body which is rotating.

 

The equation is simple:

 

P be the local position/offset in global space,

V, the linear velocity

W and angular velocity of the body

Vf = V + cross (W, P)

 

So in LE i do this:

P = Vec3(5,0,0)
V = GetBodyVelocity(body,1)
W = GetBodyOmega(body,1)
lvel = cross(bodyav,TFormPoint(offset,body,nil))
vf = AddVec(bodyV,lvel)

 

 

This caused crazy results and doesnt work, as soon as the body starts to rotate vf results in an axis having a massive number.

 

So, ive been told this is because im transforming the point and not rotating it and suggested:

 

(not LE code)

P = Vec3(5,0,0)
V = GetBodyVelocity(body,1)
W = GetBodyOmega(body,1)
globalOffset = TransformVector (bodyMatrix,P) - bodyMatrix.GetPosition()
lvel = cross(bodyav,globalOffset)
vf = AddVec(bodyV,lvel)

 

Does this make any more sense?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

In LE you should rather create a pivot, move it to the desired position and then parent it to the physics body. Then you can measure the speed of the pivot. That should be much faster than calling so many functions.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...