Class: Eigen::AngleAxis

Inherits:
Object
  • Object
show all
Defined in:
lib/eigen/angle_axis.rb,
ext/eigen/eigen.cpp

Overview

A rotation represented by an axis and angle

Class Method Summary collapse

Instance Method Summary collapse

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

.from_quaternion(*args) ⇒ Object

Creates a angle axis from a quaternion



22
23
24
25
26
# File 'lib/eigen/angle_axis.rb', line 22

def self.from_quaternion(*args)
    aa = new(0, Eigen::Vector3.new(1, 0, 0))
    aa.from_quaternion(*args)
    aa
end

.IdentityObject

Returns the identity unit quaternion (identity rotation)



17
18
19
# File 'lib/eigen/angle_axis.rb', line 17

def self.Identity
    AngleAxis.new(0, Eigen::Vector3.new(1, 0, 0))
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

#angleNumeric

The angle (in radians)

Returns:

  • (Numeric)

#approx?(aa, threshold = dummy_precision) ⇒ Boolean

Verifies that two angle-axis are within threshold of each other, elementwise

Parameters:

Returns:

  • (Boolean)

#axisVector3

The rotation axis

Returns:

#concatenate(aa) ⇒ AngleAxis

Combine this rotation with another rotation

Parameters:

Returns:

#dupObject



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

Parameters:

  • v (Vector3)

    a 3-vector where .x is roll (rotation around X), .y is pitch and .z yaw

#from_matrix(matrix) ⇒ Object

Initializes from a rotation matrix

Parameters:

#from_quaternion(q) ⇒ Object

Initializes from a quaternion

Parameters:

#inverseAngleAxis

The inverse rotation

Returns:

#matrixMatrixX

The rotation matrix equivalent to this unit quaternion

Returns:

#to_aObject

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_eulerVector3

Converts this quaternion into Euler-Bryant angles

Returns:

  • (Vector3)

    a 3-vector where .x is roll (rotation around X), .y is pitch and .z yaw

#to_sObject

: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

Parameters:

  • eps (Float) (defaults to: 1e-12)

    see #to_angle_axis

Returns:



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

Parameters:

Returns: