apple / swift-numerics

Advanced mathematical types and functions for Swift
Apache License 2.0
1.68k stars 145 forks source link

Add `isReal` to `Quaternion` and refine comments on `isPure` #204

Closed markuswntr closed 3 years ago

markuswntr commented 3 years ago

This PR adds a computed property to Quaternion that allows to check if a quaternion is a real quaternion, i.e. a quaternion with an imaginary/vector term of 0 (zero). This complements the existing property isPure, which allows to check for pure quaternions, i.e. quaternions that have a real/scalar term of 0 (zero). Note that isReal and isPure are not mutually exclusive, as a zero quaternion ([0,0]) is both pure and real.

Additionally, it adds a small refinement to the header comment of isPure.

stephentyrone commented 3 years ago

@swift-ci test