Skip to content

Commit c8a1f05

Browse files
feat : Angle between node use consistent direction
1 parent 781fa7a commit c8a1f05

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

  • node-graph/nodes/math/src

node-graph/nodes/math/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -823,11 +823,10 @@ fn dot_product(
823823

824824
/// Calculates the angle swept between two vectors.
825825
///
826-
/// The value is always positive and ranges from 0° (both vectors point the same direction) to 180° (both vectors point opposite directions).
826+
/// The value ranges from -180° to +180° (or -π to +π radians). Positive values indicate an anticlockwise rotation from A to B, while negative values indicate a clockwise rotation.
827827
#[node_macro::node(category("Math: Vector"))]
828828
fn angle_between(_: impl Ctx, vector_a: DVec2, vector_b: DVec2, radians: bool) -> f64 {
829-
let dot_product = vector_a.normalize_or_zero().dot(vector_b.normalize_or_zero());
830-
let angle = dot_product.acos();
829+
let angle = vector_a.angle_to(vector_b);
831830
if radians { angle } else { angle.to_degrees() }
832831
}
833832

0 commit comments

Comments
 (0)