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.

2 comments

0

Basically you're trying to find the angle between two lines in polar form?

0

no, im trying to create a new vector3 with trigonometry using 2 angles for raycasting