POV-Ray : Newsgroups : povray.newusers : Full 360 with VAngleD Server Time
21 Nov 2024 07:46:30 EST (-0500)
  Full 360 with VAngleD (Message 1 to 3 of 3)  
From: Bald Eagle
Subject: Full 360 with VAngleD
Date: 10 Oct 2019 06:30:01
Message: <web.5d9f06fb61410b204eec112d0@news.povray.org>
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

From: Tor Olav Kristensen
Subject: Re: Full 360 with VAngleD
Date: 10 Oct 2019 14:45:01
Message: <web.5d9f7b4becd82d81ed4479290@news.povray.org>
"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

From: Bald Eagle
Subject: Re: Full 360 with VAngleD
Date: 12 Oct 2019 21:10:00
Message: <web.5da278a2ecd82d814eec112d0@news.povray.org>
"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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.