Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to create a new 3D vector from 2 Angles?

Asked by 3 years ago

So i found out how to create a vector2 in 2D using only one angle but now i need a vector3 using two angles

The code i used to get the 2D vector:

function V2ToForce(Angle,Force)
    local Force = Force or 1
    local X,Y = math.cos(Angle)*Force,math.sin(Angle)*Force 
    return X,Y
end

I found this formula and some code for testing but acts strange the X works ok but the Y is very glitchy

function Test(X,Y,Force)
    local x = math.cos(X) * math.cos(Y);
    local z = math.sin(X) * math.cos(Y);
    local y = math.sin(Y);
    return x*Force,y*Force,z*Force
end
for _=1,360 do
    Test(math.rad(_),math.rad(_),1)
end

Any pseudocode would help.

0
Basically you're trying to find the angle between two lines in polar form? radiant_Light203 1166 — 3y
0
no, im trying to create a new vector3 with trigonometry using 2 angles for raycasting rafa_br34 5 — 3y

Answer this question