Jump to content

relative Rotation


Rotti

Recommended Posts

Posted

Hello,

I have a problem with moveObject.

The method only uses relative rotation.

I have made a xml file with waypoints and these waypoints have the x, y, z coordinates and the absolute rotation.

So now i have to calculate the relative rotation between my object and the waypoint.

I came up with this idea:

rx, ry, rz = rotation of the waypoint 
rxx, ryy, rzz = rotation of the object 
relative rotation = rx - rxx, ry - ryy, rz - rzz 

This is no code its just the math.

But the problem is that if the Y rotation of the waypoint is 359° and the Y rotation of the object is 0° it won't roll one degree to the left. Instead it will roll 359 degrees to the right which looks awful.

Can someone help me please?

Posted

You need to use math functions

math.sin() 
math.cos() 
math.rad() 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

I dont want the object to look towards the waypoint. I want it to move to the waypoint and to slowly rotate to the rotation of the waypoint

so that rx = rxx, ry = ryy, rz = rzz

I don't know how sin cos and rad could help me here...

Posted
I dont want the object to look towards the waypoint. I want it to move to the waypoint and to slowly rotate to the rotation of the waypoint

so that rx = rxx, ry = ryy, rz = rzz

I don't know how sin cos and rad could help me here...

Try to do it by yourself then post your code here and i will help u.

Also post some SS here

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

I just found this function for c# on the internet.

I translated it to lua

function calculateDifferenceBetweenAngles(firstAngle, secondAngle) 
    difference = secondAngle - firstAngle; 
    while (difference < -180) do 
        difference = difference + 360 
    end 
    while (difference > 180) do 
        difference = difference - 360 
    end 
    return difference 
end 

It works.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...