|
|
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....
Post a reply to this message
|
|
|
|
"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....
Try this:
#version 3.7;
// 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 "\n"
#debug "\n"
#debug str(Angle2D(v0, v1), 0, 12)
#debug "\n"
#debug "\n"
#error "To stop render window from opening"
NB! I have only tested this lightly.
--
Tor Olav
http://subcube.com
https://github.com/t-o-k
Post a reply to this message
|
|
|
|
"Tor Olav Kristensen" <tor### [at] TOBEREMOVEDgmailcom> wrote:
> Try this:
[snip]
> NB! I have only tested this lightly.
Thanks buddy :)
To be honest, I managed to do most of what I needed with a simple atan2d, which
kinda makes me question the usefulness of the macro.
But then I ran into other problems, declared a pox upon the complexity of the
usual belt problem solutions, and went full analytical geometry.
Now I suppose I have to figure out some sort of pointing in / pointing out test
to create a sort of "convex hull" by selecting the proper tangent line.
Truly convex parts would need the outermost outer tangent, and convex circles
would need the proper inner tangent line, so the whole thing would resemble an
automotive serpentine belt.
See pbi
Post a reply to this message
|
|