getAxisAngle method

Map<String, dynamic> getAxisAngle()

Implementation

Map<String,dynamic> getAxisAngle() {
  final angle = 2 * math.acos(w);

  // Handle edge case for zero or 180-degree rotations
  final s = math.sqrt(1 - w * w);
  final axis = Vector3();

  if (s < 0.00001) { // Angle is close to 0 or 180 degrees
    // Default axis, or handle as needed for your application
    axis.setValues(1, 0, 0);
  } else {
    axis.setValues(x / s, y / s, z / s);
  }

  return { 'axis': axis, 'angle': angle };
}