Module: TT::Point3d_Ex
- Defined in:
- TT_Lib2/point3d_ex.rb
Overview
Mix-in module for Geom::Point3d
.
Instance Method Summary collapse
-
#between?(point1, point2, on_point = true) ⇒ Boolean
Checks if a point is on line between two other points.
- #eql?(object) ⇒ Boolean
- #hash ⇒ Integer
Instance Method Details
#between?(point1, point2, on_point = true) ⇒ Boolean
Checks if a point is on line between two other points.
point1
and point2
should be a
Geom::Point3d
, Array
object, or and object that
implements a .position
method that returns a 3d position.
When on_point
is true
the method will return
true
if self
is equal to point1
or
point2
.
30 31 32 33 34 |
# File 'TT_Lib2/point3d_ex.rb', line 30 def between?( point1, point2, on_point = true ) point1 = point1.position if point1.respond_to?( :position ) point2 = point2.position if point2.respond_to?( :position ) TT::Point3d.between?( point1, point2, self, on_point = true ) end |
#eql?(object) ⇒ Boolean
41 42 43 |
# File 'TT_Lib2/point3d_ex.rb', line 41 def eql?( object ) self == object end |
#hash ⇒ Integer
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'TT_Lib2/point3d_ex.rb', line 48 def hash # (!) May return different hash for identical positions. #[self.x.to_f, self.y.to_f, self.z.to_f].hash #[self.x, self.y, self.z].hash # (!) Experimental! # Convert X, Y and Z to ints at 1000th accuracy to avoid inconsistent hash # values for identical positions. x = ( self.x * 1000 ).to_i y = ( self.y * 1000 ).to_i z = ( self.z * 1000 ).to_i [x, y, z].hash end |