View Full Version : [solved]math help: tangent vector to rotator (for splines)
kuniko
03-21-2010, 11:01 AM
Hello guys,
I was wondering if someone could give me a quick pointer, I've got a tangent vector but when I simply cast it to a rotator the Roll component is always 0, any help?
Mr Evil
03-21-2010, 11:14 AM
Vectors do not have roll information, so you can never recover it when casting to a rotator. If you can get two more vectors (one pointing 'up' and one pointing 'right') then you can use the OrthoRotation function to turn all three vectors into one rotator with roll.
handyface
03-21-2010, 11:19 AM
How do you want to transform the vector to roll? Maybe give us a bit more information (code snippets etc.)?
A vector is sort of an arrow pointing from a 0,0,0 point to a certain point in 3D space so as you can imagine, the pitch (up and down, imagine nodding yes) and the yaw (as in looking left and right) will be enough to look in the direction of a vector.
When someone is asking you to look at a bird, you wouldn't have to roll your head in a certain direction to look at the bird. This is why your roll component is 0. If you still want the camera to roll, you should define it in another way.
local rotator MyRotator;
MyRotator.Roll = ...
kuniko
03-21-2010, 11:34 AM
thanks for the replies, here is what i'm trying get:
tangent = SplineComp.GetTangentAtDistanceAlongSpline(Current Distance);
Pawn.FaceRotation(rotator(tangent), DeltaTime);
I thought that spline function would give me a perpendicular vector representing the tangent (roll), guess not?
How would I be able to extract and set the Roll value for my rotator value from a spline?
JCoelho
03-21-2010, 02:35 PM
Value of Vector = sqrt(ex^2 + ey^2 + ez^2);
kuniko
03-21-2010, 04:36 PM
Well it was actually easier than expected, for anyone else reading this, to update the roll of an actor constraint to a loft spline:
//get the roll amount of the current spline
fRoll = SplineLoftActor(StartSpline).Roll;
//calculate the difference we have to roll to the next spline
fRollDiff = SplineLoftActor(NextSpline).Roll - SplineLoftActor(StartSpline).Roll;
//the distance percentage to the next spline
DistPct = CurrentDistance / SplineLength;
//our current rotation in degree
fRoll += fRollDiff * DistPct;
//convert degree into RUU
iRoll = int(fRoll * 65536 / 360);
//assign our new roll value
ActorRot.Roll = iRoll;
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.