fixes #73 by removing the faulty vec2 proc and making the vec3 angle proc work for vec2
This commit is contained in:
parent
7282ae1247
commit
57ad916ab1
|
@ -1573,12 +1573,16 @@ proc angle*[T](a: GVec2[T]): T =
|
||||||
## Angle of a Vec2.
|
## Angle of a Vec2.
|
||||||
arctan2(a.y, a.x)
|
arctan2(a.y, a.x)
|
||||||
|
|
||||||
proc angle*[T](a, b: GVec2[T]): T =
|
proc angle*[T](a, b: GVec2[T]|GVec3[T]): T =
|
||||||
## Angle between 2 Vec2.
|
## Angle between 2 Vec2 or Vec3.
|
||||||
fixAngle(arctan2(a.y - b.y, a.x - b.x))
|
runnableExamples:
|
||||||
|
assert angle(vec2(0.0, 1.0), vec2(1.0, 0.0)).toDegrees() == 90.0
|
||||||
|
assert angle(vec2(0.0, 1.0), vec2(-1.0, 0.0)).toDegrees() == 90.0
|
||||||
|
assert angle(vec2(0.0, 1.0), vec2(0.0, -1.0)).toDegrees() == 180.0
|
||||||
|
|
||||||
proc angle*[T](a, b: GVec3[T]): T =
|
assert angle(vec3(0.0, 1.0, 0.0), vec3(1.0, 0.0, 0.0)).toDegrees() == 90.0
|
||||||
## Angle between 2 Vec3.
|
assert angle(vec3(0.0, 1.0, 0.0), vec3(-1.0, 0.0, 0.0)).toDegrees() == 90.0
|
||||||
|
assert angle(vec3(0.0, 1.0, 0.0), vec3(0.0, -1.0, 0.0)).toDegrees() == 180.0
|
||||||
var dot = dot(a, b)
|
var dot = dot(a, b)
|
||||||
dot = dot / (a.length * b.length)
|
dot = dot / (a.length * b.length)
|
||||||
arccos(dot)
|
arccos(dot)
|
||||||
|
|
Loading…
Reference in a new issue