2

I have 2 vectors A, B. Using A.angleTo(B), I know the mangitude of the angle between them.

How do I find the sign of this angle? Maybe we need to use some reference vector for this?

GaryTheBaddy
  • 123
  • 1
  • 8

2 Answers2

0

I'll suggest you to use a reference plane, personally i didn't need the sign of the angle returned from .angleTo() method so i suggest you to read this two posts:

Signed angle between two 3D vectors with same origin within the same plane

How to calculate the angle between 2 vectors in a plane

binaryRat
  • 186
  • 1
  • 11
0

Angle sign is arbitrary in 3D, so I'm assuming you mean in 2D? In which case this solution worked for me:

import {Plane, Vector3} from 'three';

export function getNormal(u: Vector3, v: Vector3): Vector3 {
    return new Plane().setFromCoplanarPoints(new Vector3(), u, v).normal;
}

export function signedAngleTo(u: Vector3, v: Vector3): number {
    // Get the signed angle between u and v, in the range [-pi, pi]
    const angle = u.angleTo(v);
    const normal = getNormal(u, v);
    return normal.z * angle;
}
serg06
  • 2,027
  • 1
  • 18
  • 26