Right now I am stuck with a rotated axis which has the correct “up” direction, but the incorrect forward and right directions. I want to swap the forward and right directions but I have no idea on how to even start on that.
local normal = getSurfaceNormal()
local UP = Vector3.new(0, 1, 0)
local axis = UP:Cross(normal);
local theta = math.rad(45)
local vAxis = CFrame.fromAxisAngle(axis, theta)
My goal is to switch the blue and black arrows, whilst keeping the red arrow the same. Any ideas?
yep, but then apply the 90 degree offset.
so like:
local normal = getSurfaceNormal()
local UP = Vector3.new(0, 1, 0)
local axis = UP:Cross(-normal);
local theta = math.rad(45)
local vAxis = CFrame.fromAxisAngle(axis, theta + math.pi/2) -- might be - math.pi/2
also you can fix this problem easily by switching the usage of the variables axis and vAxis for whatever you are using it for. You should not have to change any math at all
SwagMasterAndrew already suggested doing that, which doesn’t switch the black and blue axes, but rather creates an offset of 90* on the blue axis and doesn’t affect the black axis at all
Why would you swap the arrows? You already have references to both of them, just use the correct one where needed, if you want to swap the arrows just draw the picture using different colors.
It’s impossible to produce the axis in the picture you are showing, if the blue line is the Z axis (LookVector) and the black one is the X axis (RightVector), then you cannot swap them and change the RightVector to LeftVector, if your main goal is to change the look vector and not the right vector then you could just rotate the axis by 90 degrees on any direction you want, Here is how it should look like in an image by the way
For the code you could try this (I haven’t tested it)
local OriginalAxis = getSurfaceNormal() -- Just set this the the initial CFrame (Must be CFrame)
local Degrees = 90
local NewAxis = OriginalAxis * CFrame.Angles(0,math.rad(Degrees),0)