computeNormal static method

Vector3 computeNormal(
  1. Vector3 va,
  2. Vector3 vb,
  3. Vector3 vc,
  4. Vector3 target,
)

Get face normal given 3 vertices

Implementation

static Vector3 computeNormal(final Vector3 va, final Vector3 vb, final Vector3 vc, final Vector3 target) {
  final cb = Vector3.zero();
  final ab = Vector3.zero();
  vb.sub2(va, ab);
  vc.sub2(vb, cb);
  cb.cross2(ab, target);
  if (!target.isZero()) {
    target.normalize();
  }

  return target;
}