class Geom3d::Point
Attributes
x[RW]
y[RW]
z[RW]
Public Class Methods
new(*args)
click to toggle source
# File lib/geom3d/point.rb, line 8 def initialize *args @x, @y, @z = args.flatten end
Public Instance Methods
+(other)
click to toggle source
# File lib/geom3d/point.rb, line 23 def + other Point.new(@x + other.dx, @y + other.dy, @z + other.dz) end
-(other)
click to toggle source
# File lib/geom3d/point.rb, line 12 def - other case other when Point Vector.new(@x - other.x, @y - other.y, @z - other.z) when Vector Point.new(@x - other.dx, @y - other.dy, @z - other.dz) else throw ArgumentError end end
==(other)
click to toggle source
# File lib/geom3d/point.rb, line 27 def == other (@x - other.x) < EPS && (@y - other.y) < EPS && (@z - other.z) < EPS end
flatten()
click to toggle source
# File lib/geom3d/point.rb, line 40 def flatten to_ary.flatten end
to_ary()
click to toggle source
Allows recursive flatten and multiple assignment to work with this class
# File lib/geom3d/point.rb, line 36 def to_ary [@x, @y, @z] end
to_s()
click to toggle source
# File lib/geom3d/point.rb, line 31 def to_s "Point3(%.3f,%.3f,%.3f)" % [@x, @y, @z] end