module Silicium::Geometry3d
Constants
- Point3d
Represents a point as three coordinates in three-dimensional space
Public Instance Methods
Creates an array- directing vector in three-dimensional space . The equation is specified in the canonical form. Example, (x-0) / 26 = (y + 300) / * (- 15) = (z-200) / 51
Important: mandatory order of variables: x, y, z
# File lib/geometry3d.rb, line 241 def directing_vector3d(line_equation) process_line_by_coordinates(line_equation, :process_cf) end
Calculates the distance from given points in three-dimensional space
# File lib/geometry3d.rb, line 15 def distance_point_to_point3d(a, b) Math.sqrt((b.x - a.x)**2 + (b.y - a.y)**2 + (b.z - a.z)**2) end
Creates an array of coordinates of the point ([x, y, z] on the line given by the equation in the canonical form. Example, (x-0) / 26 = (y + 300) / * (- 15) = (z-200) / 51
Important: mandatory order of variables: x, y, z
# File lib/geometry3d.rb, line 251 def height_point_3d(line_equation) process_line_by_coordinates(line_equation, :process_free_member) end
Calculates the distance from a point given by a Point3d
structure to a straight line given by a canonical equation. Example, (x-0) / 26 = (y + 300) / * (- 15) = (z-200) / 51
Important: mandatory order of variables: x, y, z
# File lib/geometry3d.rb, line 261 def point_to_line_distance_3d(point, line_eq) dir_vector = directing_vector3d(line_eq) line_point = height_point_3d(line_eq) height_vector = [line_point[0] - point.x, line_point[1] - point.y, line_point[2] - point.z] height_on_dir = vectors_product(height_vector, dir_vector) vector_length(height_on_dir) / vector_length(dir_vector) end