Skip to content

Commit

Permalink
Fix creating AxisAngle from identity quaternion (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
httpdigest committed Jul 26, 2020
1 parent 1627a32 commit 57fb50c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
40 changes: 20 additions & 20 deletions src/org/joml/AxisAngle4d.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ public AxisAngle4d(Quaternionfc q) {
float acos = Math.safeAcos(q.w());
float invSqrt = Math.invsqrt(1.0f - q.w() * q.w());
if (Float.isInfinite(invSqrt)) {
this.x = 0.0;
this.y = 0.0;
this.z = 1.0;
this.x = 0.0;
this.y = 0.0;
this.z = 1.0;
} else {
this.x = q.x() * invSqrt;
this.x = q.x() * invSqrt;
this.y = q.y() * invSqrt;
this.z = q.z() * invSqrt;
}
Expand All @@ -128,14 +128,14 @@ public AxisAngle4d(Quaternionfc q) {
* the quaternion from which to create the new AngleAxis4d
*/
public AxisAngle4d(Quaterniondc q) {
double acos = Math.safeAcos(q.w());
double invSqrt = Math.invsqrt(1.0 - q.w() * q.w());
double acos = Math.safeAcos(q.w());
double invSqrt = Math.invsqrt(1.0 - q.w() * q.w());
if (Double.isInfinite(invSqrt)) {
this.x = 0.0;
this.y = 0.0;
this.z = 1.0;
this.x = 0.0;
this.y = 0.0;
this.z = 1.0;
} else {
this.x = q.x() * invSqrt;
this.x = q.x() * invSqrt;
this.y = q.y() * invSqrt;
this.z = q.z() * invSqrt;
}
Expand Down Expand Up @@ -270,11 +270,11 @@ public AxisAngle4d set(Quaternionfc q) {
float acos = Math.safeAcos(q.w());
float invSqrt = Math.invsqrt(1.0f - q.w() * q.w());
if (Float.isInfinite(invSqrt)) {
this.x = 0.0;
this.y = 0.0;
this.z = 1.0;
this.x = 0.0;
this.y = 0.0;
this.z = 1.0;
} else {
this.x = q.x() * invSqrt;
this.x = q.x() * invSqrt;
this.y = q.y() * invSqrt;
this.z = q.z() * invSqrt;
}
Expand All @@ -291,14 +291,14 @@ public AxisAngle4d set(Quaternionfc q) {
* @return this
*/
public AxisAngle4d set(Quaterniondc q) {
double acos = Math.safeAcos(q.w());
double invSqrt = Math.invsqrt(1.0f - q.w() * q.w());
double acos = Math.safeAcos(q.w());
double invSqrt = Math.invsqrt(1.0f - q.w() * q.w());
if (Double.isInfinite(invSqrt)) {
this.x = 0.0;
this.y = 0.0;
this.z = 1.0;
this.x = 0.0;
this.y = 0.0;
this.z = 1.0;
} else {
this.x = q.x() * invSqrt;
this.x = q.x() * invSqrt;
this.y = q.y() * invSqrt;
this.z = q.z() * invSqrt;
}
Expand Down
30 changes: 15 additions & 15 deletions src/org/joml/AxisAngle4f.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ public AxisAngle4f(Quaternionfc q) {
float acos = Math.safeAcos(q.w());
float invSqrt = Math.invsqrt(1.0f - q.w() * q.w());
if (Float.isInfinite(invSqrt)) {
this.x = 0.0f;
this.y = 0.0f;
this.z = 1.0f;
this.x = 0.0f;
this.y = 0.0f;
this.z = 1.0f;
} else {
this.x = q.x() * invSqrt;
this.x = q.x() * invSqrt;
this.y = q.y() * invSqrt;
this.z = q.z() * invSqrt;
}
Expand Down Expand Up @@ -208,14 +208,14 @@ public AxisAngle4f set(float angle, Vector3fc v) {
* @return this
*/
public AxisAngle4f set(Quaternionfc q) {
float acos = Math.safeAcos(q.w());
float acos = Math.safeAcos(q.w());
float invSqrt = Math.invsqrt(1.0f - q.w() * q.w());
if (Float.isInfinite(invSqrt)) {
this.x = 0.0f;
this.y = 0.0f;
this.z = 1.0f;
this.x = 0.0f;
this.y = 0.0f;
this.z = 1.0f;
} else {
this.x = q.x() * invSqrt;
this.x = q.x() * invSqrt;
this.y = q.y() * invSqrt;
this.z = q.z() * invSqrt;
}
Expand All @@ -232,14 +232,14 @@ public AxisAngle4f set(Quaternionfc q) {
* @return this
*/
public AxisAngle4f set(Quaterniondc q) {
double acos = Math.safeAcos(q.w());
double invSqrt = Math.invsqrt(1.0 - q.w() * q.w());
double acos = Math.safeAcos(q.w());
double invSqrt = Math.invsqrt(1.0 - q.w() * q.w());
if (Double.isInfinite(invSqrt)) {
this.x = 0.0f;
this.y = 0.0f;
this.z = 1.0f;
this.x = 0.0f;
this.y = 0.0f;
this.z = 1.0f;
} else {
this.x = (float) (q.x() * invSqrt);
this.x = (float) (q.x() * invSqrt);
this.y = (float) (q.y() * invSqrt);
this.z = (float) (q.z() * invSqrt);
}
Expand Down

0 comments on commit 57fb50c

Please sign in to comment.