Skip to content

Commit

Permalink
Fixed wrong log and exp
Browse files Browse the repository at this point in the history
  • Loading branch information
HexagonNico committed Oct 29, 2023
1 parent acdb4ca commit ef83fe5
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,21 +311,21 @@ case class Quaternion(w: Double, x: Double, y: Double, z: Double) extends Double
*
* @return The exponential of this quaternion
*/
def exp: Double = {
def exp: Quaternion = {
val v = Vec3d(this.x, this.y, this.z)
val length = v.length
math.exp(this.w) * (math.cos(length) + v / v.length * math.sin(length))
Quaternion(math.exp(this.w), math.cos(length) + v / v.length * math.sin(length))
}

/**
* Returns the [[https://en.wikipedia.org/wiki/Quaternion#Exponential,_logarithm,_and_power_functions logarithm]] of this quaternion.
*
* @return The logarithm of this quaternion
*/
def log: Double = {
def log: Quaternion = {
val v = Vec3d(this.x, this.y, this.z)
val length = this.length
math.log(length) + v.normalized * math.acos(this.w / length)
Quaternion(math.log(length), v.normalized * math.acos(this.w / length))
}

/**
Expand Down

0 comments on commit ef83fe5

Please sign in to comment.