Module: Geom
Overview
Lines and Planes are infinite.
The Geom module defines a number of Module methods that let you perform different geometric operations.
The methods in this module take lines and planes as arguments. There is no special class for representing lines or planes. Arrays are used for both.
A line can be represented as either an Array of a point and a vector, or as an Array of two points.
line1 = [Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0, 0, 1)]
line2 = [Geom::Point3d.new(0, 0, 0), Geom::Point3d.new(0, 0, 100)]
A plane can be represented as either an Array of a point and a vector, or as an Array of 4 numbers that give the coefficients of a plane equation.
plane1 = [Geom::Point3d.new(0, 0, 0), Geom::Vector3d.new(0, 0, 1)]
plane2 = [0, 0, 1, 0]
There are several good books on 3D math if you are new to the concepts of a line, plane, and vector.
Defined Under Namespace
Classes: BoundingBox, Bounds2d, LatLong, OrientedBounds2d, Point2d, Point3d, PolygonMesh, Transformation, Transformation2d, UTM, Vector2d, Vector3d
Class Method Summary # collapse

.closest_points(line1, line2) ⇒ Array(Geom::Point3d, Geom::Point3d)
The Geom.closest_points method is used to compute the closest points on two lines.

.fit_plane_to_points(*args) ⇒ Object
The Geom.fit_plane_to_points method is used to compute a plane that is a best fit to an array of points.

.intersect_line_line(line1, line2) ⇒ Geom::Point3d^{?}
The Geom.intersect_line_line computes the intersection of two lines.

.intersect_line_plane(line, plane) ⇒ Geom::Point3d^{?}
The Geom.intersect_line_plane method is used to compute the intersection of a line and a plane.

.intersect_plane_plane(plane1, plane2) ⇒ Array(Geom::Point3d, Geom::Vector3d)
The Geom.intersect_plane_plane method is used to compute the intersection of two planes.

.linear_combination(weight1, pt_or_vect1, weight2, pt_or_vect2) ⇒ Object
The Geom.linear_combination method is used to compute the linear combination of points or vectors.

.point_in_polygon_2D(point, polygon, check_border) ⇒ Boolean
The Geom.point_in_polygon_2D method is used to determine whether a point is inside a polygon.

.tesselate(polygon_loop_points, *inner_loop_points) ⇒ Array<Geom::Point3d>
Tessellates a polygon, represented as a collection of 3D points.
Class Method Details
↑ .closest_points(line1, line2) ⇒ Array(Geom::Point3d, Geom::Point3d)
The closest_points method is used to compute the closest points on two lines.
line.
↑ .fit_plane_to_points(point1, point2, point3, ...) ⇒ Array(Geom::Point3d, Geom::Vector3d) .fit_plane_to_points(points) ⇒ Array(Geom::Point3d, Geom::Vector3d)
The fit_plane_to_points method is used to compute a plane that is a best fit to an array of points. If more than three points are given some of the points may not be on the plane.
The plane is returned as an Array of 4 numbers which are the coefficients of the plane equation Ax + By + Cz + D = 0
.
↑ .intersect_line_line(line1, line2) ⇒ Geom::Point3d^{?}
The intersect_line_line computes the intersection of two lines.
↑ .intersect_line_plane(line, plane) ⇒ Geom::Point3d^{?}
The intersect_line_plane method is used to compute the intersection of a line and a plane.
↑ .intersect_plane_plane(plane1, plane2) ⇒ Array(Geom::Point3d, Geom::Vector3d)
The intersect_plane_plane method is used to compute the intersection of two planes.
↑ .linear_combination(weight1, point1, weight2, point2) ⇒ Geom::Point3d .linear_combination(weight1, vector1, weight2, vector2) ⇒ Geom::Vector3d
The linear_combination method is used to compute the linear combination of points or vectors.
A linear combination is a standard term for vector math. It is defined as vector = weight1 * vector1 + weight2 * vector2.
↑ .point_in_polygon_2D(point, polygon, check_border) ⇒ Boolean
The point_in_polygon_2D method is used to determine whether a point is inside a polygon. The z component of both the point you're checking and the points in the polygon are ignored, effectively making it a 2d check.
↑ .tesselate(polygon_loop_points, *inner_loop_points) ⇒ Array<Geom::Point3d>
The winding order of the polygons matter. The outer loop should be in counterclockwise order. To cut an empty hole the inner loops should be in clockwise order, otherwise they will create a loop filled with triangles.
The tesselation is using the same logic as SketchUp its rendering pipeline. But the exact result is an implementation detail which may change between versions. In particularly the results of degenerate polygons and nonplanar polygons is undefined as part of the API contract. Such polygons are for example polygons where all points are colinear, polygons with duplicate points, nonplanar polygons.
If you want the triangles from an existing Sketchup::Face it's better to use Sketchup::Face#mesh.
Tessellates a polygon, represented as a collection of 3D points. Can include holes by providing collections of points describing the inner loops. This is intended to be used for planar polygons.
Useful to draw concave polygons using Sketchup::View#draw or Sketchup::View#draw2d.
It can also be useful for importers where the input format describes only the loops for a polygon and you want to work with a collection of triangles.
Polygon with two holes, one empty and one filled:
(See “Drawing a polygon with holes from a custom tool” example)