Class: Eigen::AngleAxis
- Inherits:
-
Object
- Object
- Eigen::AngleAxis
- Defined in:
- lib/eigen/angle_axis.rb,
ext/eigen/eigen.cpp
Overview
A rotation represented by an axis and angle
Class Method Summary collapse
-
._load(coordinates) ⇒ Object
:nodoc:.
-
.from_euler(*args) ⇒ Object
Creates a quaternion from a set of euler angles.
-
.from_matrix(m) ⇒ Object
Creates a quaternion from a rotation matrix.
-
.from_quaternion(*args) ⇒ Object
Creates a angle axis from a quaternion.
-
.Identity ⇒ Object
Returns the identity unit quaternion (identity rotation).
Instance Method Summary collapse
-
#*(obj) ⇒ Object
Concatenates with another angle axis or transforms a vector.
-
#==(q) ⇒ Object
Tests for equality.
-
#_dump(level) ⇒ Object
:nodoc:.
-
#angle ⇒ Numeric
The angle (in radians).
-
#approx?(aa, threshold = dummy_precision) ⇒ Boolean
Verifies that two angle-axis are within threshold of each other, elementwise.
-
#axis ⇒ Vector3
The rotation axis.
-
#concatenate(aa) ⇒ AngleAxis
Combine this rotation with another rotation.
- #dup ⇒ Object
- #from_a(array) ⇒ Object
-
#from_euler(v) ⇒ Object
Initializes from euler angles.
-
#from_matrix(matrix) ⇒ Object
Initializes from a rotation matrix.
-
#from_quaternion(q) ⇒ Object
Initializes from a quaternion.
-
#inverse ⇒ AngleAxis
The inverse rotation.
-
#matrix ⇒ MatrixX
The rotation matrix equivalent to this unit quaternion.
-
#to_a ⇒ Object
Returns the angle axis as [angle, x, y, z].
-
#to_euler ⇒ Vector3
Converts this quaternion into Euler-Bryant angles.
-
#to_s ⇒ Object
:nodoc:.
-
#to_scaled_axis(eps = 1e-12) ⇒ Vector3
Returns a scaled axis representation that is equivalent to this quaternion.
-
#transform(v) ⇒ Vector3
Apply this rotation on a 3-vector.
Class Method Details
._load(coordinates) ⇒ Object
:nodoc:
66 67 68 69 70 |
# File 'lib/eigen/angle_axis.rb', line 66 def self._load(coordinates) # :nodoc: aa = new(0, Eigen::Vector3.new(1, 0, 0)) aa.from_a(Marshal.load(coordinates)) aa end |
.from_euler(*args) ⇒ Object
Creates a quaternion from a set of euler angles.
See Quaternion#from_euler for details
31 32 33 34 35 |
# File 'lib/eigen/angle_axis.rb', line 31 def self.from_euler(*args) aa = new(0, Eigen::Vector3.new(1, 0, 0)) aa.from_euler(*args) aa end |
.from_matrix(m) ⇒ Object
Creates a quaternion from a rotation matrix
38 39 40 41 42 |
# File 'lib/eigen/angle_axis.rb', line 38 def self.from_matrix(m) aa = new(0, Eigen::Vector3.new(1, 0, 0)) aa.from_matrix(m) aa end |
Instance Method Details
#*(obj) ⇒ Object
Concatenates with another angle axis or transforms a vector
54 55 56 57 58 59 60 |
# File 'lib/eigen/angle_axis.rb', line 54 def *(obj) if obj.kind_of?(AngleAxis) concatenate(obj) else transform(obj) end end |
#==(q) ⇒ Object
Tests for equality
Since Quaternion stores the coordinates as floating-point values, this is a bad test. Use
(v - other_v).norm < threshold
instead
84 85 86 87 |
# File 'lib/eigen/angle_axis.rb', line 84 def ==(q) q.kind_of?(self.class) && __equal__(q) end |
#_dump(level) ⇒ Object
:nodoc:
62 63 64 |
# File 'lib/eigen/angle_axis.rb', line 62 def _dump(level) # :nodoc: Marshal.dump(to_a) end |
#angle ⇒ Numeric
The angle (in radians)
#approx?(aa, threshold = dummy_precision) ⇒ Boolean
Verifies that two angle-axis are within threshold of each other, elementwise
#axis ⇒ Vector3
The rotation axis
#concatenate(aa) ⇒ AngleAxis
Combine this rotation with another rotation
#dup ⇒ Object
4 5 6 |
# File 'lib/eigen/angle_axis.rb', line 4 def dup AngleAxis.new(angle, axis) end |
#from_a(array) ⇒ Object
11 12 13 14 |
# File 'lib/eigen/angle_axis.rb', line 11 def from_a (array) aa = AngleAxis.new(array[0], Eigen::Vector3.new(array[1][0], array[1][1], array[1][2])) aa end |
#from_euler(v) ⇒ Object
Initializes from euler angles
#from_matrix(matrix) ⇒ Object
Initializes from a rotation matrix
#from_quaternion(q) ⇒ Object
Initializes from a quaternion
#inverse ⇒ AngleAxis
The inverse rotation
#matrix ⇒ MatrixX
The rotation matrix equivalent to this unit quaternion
#to_a ⇒ Object
Returns the angle axis as [angle, x, y, z]
9 |
# File 'lib/eigen/angle_axis.rb', line 9 def to_a; [angle, axis.to_a] end |
#to_euler ⇒ Vector3
Converts this quaternion into Euler-Bryant angles
#to_s ⇒ Object
:nodoc:
72 73 74 |
# File 'lib/eigen/angle_axis.rb', line 72 def to_s # :nodoc: "AngleAxis( angle #{angle}, axis(#{axis.x}, #{axis.y}, #{axis.z}))" end |
#to_scaled_axis(eps = 1e-12) ⇒ Vector3
Returns a scaled axis representation that is equivalent to this quaternion
49 50 51 |
# File 'lib/eigen/angle_axis.rb', line 49 def to_scaled_axis(eps = 1e-12) return axis * angle end |
#transform(v) ⇒ Vector3
Apply this rotation on a 3-vector