# How to get Positive and Negative Degrees (Angle Node)?

**URL:** <https://discourse.mcneel.com/t/how-to-get-positive-and-negative-degrees-angle-node/153162>\
**Category:** Grasshopper\
**Tags:** windows\
**Created:** [January 11, 2023, 12:58pm UTC](https://discourse.mcneel.com/t/how-to-get-positive-and-negative-degrees-angle-node/153162 "2023-01-11T12:58:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RANE](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/rane/32/635408_2.png) [@RANE](https://discourse.mcneel.com/u/RANE)\
**Post date:** [January 11, 2023, 12:58pm UTC](https://discourse.mcneel.com/t/how-to-get-positive-and-negative-degrees-angle-node/153162/1 "2023-01-11T12:58:17Z")

</div>

Hello everyone,  
I am using the Angle node to get radians between two vectors. Later I convert them to Degrees, but I only get Positive(+) degrees. I need both Positive (+) and Negative (-) degrees to move ahead. I am attaching my grasshopper file below.

 ![1](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/2/7/c/27c99e48ffd6101f107cf3931b3dd042ac7d9baf.jpeg)  
 ![2](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/4/d/7/4d716f811c699cc6774b34a78040601559a817d0.jpeg)  
[Angle problem.gh](https://discourse.mcneel.com/uploads/short-url/7e29tmkW1abVqopjs35Dx3K66iF.gh) (15.4 KB)

---

<div class="post-metadata">

**Author:** ![farouk.serragedine](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/farouk.serragedine/32/770975_2.png) [@farouk.serragedine](https://discourse.mcneel.com/u/farouk.serragedine)\
**Post date:** [January 11, 2023, 1:02pm UTC](https://discourse.mcneel.com/t/how-to-get-positive-and-negative-degrees-angle-node/153162/2 "2023-01-11T13:02:33Z")

</div>

> [@RANE](#):
>
> I am using the Angle node to get radians between two vectors. Later I convert them to Degrees, but I only get Positive(+) degrees. I need both Positive (+) and Negative (-) degrees to move ahead.

The Angle node in RhinoCommon returns the angle between two vectors in radians, and this value is always positive. If you want to get a signed angle in degrees (i.e. an angle that can be positive or negative), you can use the following approach:

```auto
double signedAngleInDegrees = angleInDegrees * Vector3d.VectorProduct(vec1, vec2).Z;

```

The `Vector3d.VectorProduct(vec1, vec2)` calculates the vector product of the two vectors, which has the direction of the angle of rotation. The Z component is positive for counter-clockwise rotations, and negative for clockwise rotations. So, by multiplying the angle in degrees by the Z component of the cross product, you will get the angle in degrees, with a positive or negative value depending on the rotation direction of the angle.

Alternatively, you could also use the Vector3d.UnsignedAngle method, and then use Math.Sign method of the Math class to get the sign of the angle and multiply it by the angle obtained from the UnsignedAngle Method.

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gijs/32/769882_2.png) [@Gijs](https://discourse.mcneel.com/u/Gijs)\
**Post date:** [January 11, 2023, 1:13pm UTC](https://discourse.mcneel.com/t/how-to-get-positive-and-negative-degrees-angle-node/153162/3 "2023-01-11T13:13:43Z")

</div>

@RANE @farouk.serragedine fwiw I found this to be useful:

```python
def signedVectorAngle(v1, v2, plane):
    """
    Calculates the signed vector angle between two
    vectors v1 and v2.
    """
    # signed angle calculation, see:
    # https://stackoverflow.com/a/33920320
    return math.atan2(Vector3d.CrossProduct(v1, v2) * plane.ZAxis, v1 * v2)

```

---

<div class="post-metadata">

**Author:** ![magicteddy](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@magicteddy](https://discourse.mcneel.com/u/magicteddy)\
**Post date:** [January 11, 2023, 1:47pm UTC](https://discourse.mcneel.com/t/how-to-get-positive-and-negative-degrees-angle-node/153162/4 "2023-01-11T13:47:03Z")

</div>

You need to provide a plane (World XZ) so that the component calculates an oriented angle, otherwise it just takes the absolute value. See more ideas in this thread !

> [@Basics - Angles between two vectors and (IF THEN ELSE) regrouping](https://discourse.mcneel.com/t/basics-angles-between-two-vectors-and-if-then-else-regrouping/152413):
>
> Hi all, two basic questions in one thread. I have a 3D polyline (road red line) to which I would like to measure the angles to the vector projected on the horizontal plane (basically the road inclination). I managed to do so but : I cannot find positive and negative values. The work around I found was to define the origin of the projection to 0,0,0. In this case I have small and big numbers and I can spot where the inclinaison because negative (downwards) If (alpha \> 180) then (alpha -360). …

I like the cross/dot product approach also, it’s doable with components.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/8/e/0/8e08f38474c0fefd235c260be021d62e10328803.png)

[Angle problem.gh](https://discourse.mcneel.com/uploads/short-url/nNi0Pmjj08582TW96GxJf3HlCtw.gh) (25.2 KB)

---

<div class="post-metadata">

**Author:** ![RANE](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/rane/32/635408_2.png) [@RANE](https://discourse.mcneel.com/u/RANE)\
**Post date:** [January 11, 2023, 2:14pm UTC](https://discourse.mcneel.com/t/how-to-get-positive-and-negative-degrees-angle-node/153162/5 "2023-01-11T14:14:12Z")

</div>

@farouk.serragedine @Gijs @magicteddy  
The def works thank you…
