Class ODE::Position
In: lib/ode/position.rb  (CVS)
Parent: ODE::Vector

Instances of this class represent the position of a point in an ODE::World simulation.

Methods

distance   new   to_s  

Constants

Version = /([\d\.]+)/.match( %q{$Revision: 1.2 $} )[1]   Class constants
Rcsid = %q$Id: position.rb 91 2005-07-27 23:45:01Z ged $
Origin = new(0,0,0)

Public Class methods

Create and return a new Position object with the specified coordinates.

[Source]

# File lib/ode/position.rb, line 52
        def initialize( x=0, y=0, z=0 )
            super( x, y, z )
        end

Public Instance methods

Returns the receiver’s distance from the other ODE::Position.

[Source]

# File lib/ode/position.rb, line 59
        def distance( other=Origin )
            raise TypeError, "no implicit conversion from %s to %s" %
                [ other.class.name, self.class.name ] unless
                other.is_a?( ODE::Position )

            return Math::sqrt( (self.x - other.x) ** 2 +
                               (self.y - other.y) ** 2 +
                               (self.z - other.z) ** 2 )
                              
        end

Returns a human-readable string representing the position

[Source]

# File lib/ode/position.rb, line 71
        def to_s
            "|x = %0.2f, y = %0.2f, z = %0.2f|" %
                [self.x, self.y, self.z]
        end

[Validate]