Class: Coords::Shapes::Line3d
- Inherits:
-
Line2d
- Object
- Line2d
- Coords::Shapes::Line3d
show all
- Defined in:
- lib/coords/shapes/line3d.rb
Instance Method Summary
collapse
Methods inherited from Line2d
#==, #ends, #length, #length_squared, #point1, #point2
Constructor Details
#initialize(x1, y1, z1, x2, y2, z2) ⇒ Line3d
Returns a new instance of Line3d.
5
6
7
8
|
# File 'lib/coords/shapes/line3d.rb', line 5
def initialize(x1, y1, z1, x2, y2, z2)
@point1 = Coords::Cartesian3d.new(x1, y1, z1)
@point2 = Coords::Cartesian3d.new(x2, y2, z2)
end
|
Instance Method Details
#to_s ⇒ Object
10
11
12
|
# File 'lib/coords/shapes/line3d.rb', line 10
def to_s
"(#{point1.x.to_s},#{point1.y.to_s},#{point1.z.to_s}),(#{point2.x.to_s},#{point2.y.to_s},#{point2.z.to_s})"
end
|
#translate(x2, y2, z2) ⇒ Object
14
15
16
17
18
|
# File 'lib/coords/shapes/line3d.rb', line 14
def translate(x2, y2, z2)
translated_line = Line3d.new(point1.x, point1.y, point1.z, point2.x, point2.y, point2.z)
translated_line.translate!(x2, y2, z2)
translated_line
end
|
#translate!(x2, y2, z2) ⇒ Object
20
21
22
23
|
# File 'lib/coords/shapes/line3d.rb', line 20
def translate!(x2, y2, z2)
point1.translate!(x2, y2, z2)
point2.translate!(x2, y2, z2)
end
|