# Angle between two 3-D vectors

**URL:** <https://discourse.mcneel.com/t/angle-between-two-3-d-vectors/42970>\
**Category:** Scripting\
**Created:** [April 8, 2017, 8:51pm UTC](https://discourse.mcneel.com/t/angle-between-two-3-d-vectors/42970 "2017-04-08T20:51:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikthor](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/vikthor/32/436812_2.png) [@vikthor](https://discourse.mcneel.com/u/vikthor)\
**Post date:** [April 8, 2017, 8:51pm UTC](https://discourse.mcneel.com/t/angle-between-two-3-d-vectors/42970/1 "2017-04-08T20:51:49Z")

</div>

Do not run this  
Sorry to interrupt you. But I was in need of something like this but not running  
Someone help me anyway  
Thanks Mcneel

> ’ Description:  
> ’ Calculates the angle between two 3-D vectors.  
> ’ Parameters:  
> ’ v0 - [in] - the first vector.  
> ’ v1 - [in] - the second vector.  
> ’ Returns:  
> ’ the angle in degrees.

> Function VectorAngle(v0, v1)

> Dim u0 : u0 = Rhino.VectorUnitize(v0)  
> Dim u1 : u1 = Rhino.VectorUnitize(v1)  
> Dim dot : dot = Rhino.VectorDotProduct(u0, u1)

> ’ Force the dot product of the two input vectors to  
> ’ fall within the domain for inverse cosine, which  
> ’ is -1 \<= x \<= 1. This will prevent runtime  
> ’ “domain error” math exceptions.  
> If (dot \< -1.0) Then  
> dot = -1.0  
> ElseIf (dot \> 1.0) Then  
> dot = 1.0  
> End If

> VectorAngle = Rhino.ToDegrees(Rhino.ACos(dot))

> End Function

vikthor

---

<div class="post-metadata">

**Author:** ![AndersDeleuran](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/andersdeleuran/32/476683_2.png) [@AndersDeleuran](https://discourse.mcneel.com/u/AndersDeleuran)\
**Post date:** [April 8, 2017, 10:30pm UTC](https://discourse.mcneel.com/t/angle-between-two-3-d-vectors/42970/2 "2017-04-08T22:30:04Z")

</div>

You could also simply use the [Rhino.Geometry.Vector3d.VectorAngle](http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Vector3d_VectorAngle.htm) method.

---

<div class="post-metadata">

**Author:** ![AndersDeleuran](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/andersdeleuran/32/476683_2.png) [@AndersDeleuran](https://discourse.mcneel.com/u/AndersDeleuran)\
**Post date:** [April 10, 2017, 7:42am UTC](https://discourse.mcneel.com/t/angle-between-two-3-d-vectors/42970/4 "2017-04-10T07:42:31Z")

</div>

Perhaps [Rhino.Geometry.AngularDimension] ([http://developer.rhino3d.com/api/RhinoCommon/html/T\_Rhino\_Geometry\_AngularDimension.htm](http://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_Geometry_AngularDimension.htm)) is what you’re looking for. I believe you just add it to the Rhino document after instantiating it…
