dimforge / dimforge/nalgebra

Suggestion, implement an axis angle object instead of creating rotations from angle * axis

Open
#1,147 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
4.8k
Forks
565
PR merge metrics
No merged PRs in 30d

Description

Consider this snippet:

```rust
let axis_angle : Vec3 = axis.normalize() * angle;
camera.rotation *= na::UnitQuaternion::::new(axis_angle);
```

Assume that axis and angle are computed from the cross and dot products of 2 vectors. If the 2 vectors are aligned then the axis is NAN. Making the axis invalid.

But if you pass them as two separate objects like how C++'s eigen does it, the library can check that the angle is 0 and return a unit quaternion without incurring nans, like this:

```rust
let axis =
if Float::abs(angle) > 0.0 { vb.cross(&va) } else { Vec3::new(0.0, 1.0, 0.0) };
```

It would make the library more numerically robust.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.