tangents method

void tangents(
  1. Vector3 t1,
  2. Vector3 t2
)

Compute two artificial tangents to the vector @param t1 Vector object to save the first tangent in @param t2 Vector object to save the second tangent in

Implementation

void tangents(Vector3 t1, Vector3 t2){
  final norm = length;
  if (norm > 0.0) {
    final n = vec3TangentsN;
    final inorm = 1 / norm;
    n.setValues(x * inorm, y * inorm, z * inorm);
    final randVec = vec3TangentsRandVec;
    if (n.x.abs() < 0.9) {
      randVec.setValues(1, 0, 0);
      n.cross2(randVec, t1);
    } else {
      randVec.setValues(0, 1, 0);
      n.cross2(randVec, t1);
    }
    n.cross2(t1, t2);
  } else {
    // The normal length is zero, make something up
    t1.setValues(1, 0, 0);
    t2.setValues(0, 1, 0);
  }
}