"Bald Eagle" <cre### [at] netscapenet> wrote:
> Trying to use VAngleD with a 2D vector and x only gives me 0 to 180 deg.
> Hoping that someone can provide a simple way to get a 0 to 360 result.
> Perhaps update the distro to perform this (as a new macro?) or at least comment
> the existing macro to reflect this, and maybe add the crucial code in the
> comment as well)
> Have to head out to work, so....
// Calculate the angle from vA to vB in 2D
#macro Angle2D(vA, vB)
#local AngleA = atan2(vA.v, vA.u);
#local AngleB = atan2(vB.v, vB.u);
#local dAngle = AngleB - AngleA;
degrees(dAngle) // For result from -180 to +180 degrees
// degrees(mod(dAngle + 2*pi, 2*pi)) // For result from 0 to +360 degrees
#end // macro Angle2D
#declare v0 = <-2, 3>;
#declare v1 = <3, 2>;
#debug str(Angle2D(v0, v1), 0, 12)
#error "To stop render window from opening"
NB! I have only tested this lightly.
Post a reply to this message