module Geom |
Parent: N/A |
|
Methods:closest_points, fit_plane_to_points, intersect_line_line, intersect_line_plane, intersect_plane_plane, linear_combination, point_in_polygon_2d |
|
Sample Code:GeomTests.rb |
|
Module Methods |
closest_points |
The closest_points method is used to compute the closest points on two lines. |
Syntax: |
pts = Geom.closest_points line1, line2 |
Arguments: |
|
Return Value: |
pts - an array of two points. The first point is on the first line and the second point is on the second line. |
Comments: |
|
Example: |
line1 = [Geom::Point3d.new(0,0,0), Geom::Vector3d.new(0,0,1)] |
fit_plane_to_points |
The fit_plane_to_points method is used to compute a plane that is a best fit to an array of points |
Syntax: |
plane = Geom.fit_plane_to_points points plane = Geom.fit_plane_to_points point1, point2, point3, ... |
Arguments: |
points - an array of points point1, point2, point3 - Point3D objects |
Return Value: |
plane - a plane |
Comments: |
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 |
Example: |
point1 = Geom::Point3d.new 0,0,0 |
intersect_line_line |
The intersect_line_line computes the intersection of two lines. |
Syntax: |
point = Geom.intersect_line_line line1, line2 |
Arguments: |
line1, line2 - A line is given as either an array of a point and a vector, or an Array or two points. |
Return Value: |
Returns nil if they do not intersect. |
Comments: |
|
Example: |
line1=[Geom::Point3d.new(10,0,0),Geom::Vector3d.new(1,0,0)] |
intersect_line_plane |
The intersect_line_plane method is used to compute the intersection of a line and a plane. |
Syntax: |
point = Geom.intersect_line_plane line, plane |
Arguments: |
line - a line plane - a plane |
Return Value: |
point - a Point3d object |
Comments: |
|
Example: |
# This is really the normal which follows
the x axis. The plane is |
intersect_plane_plane |
The intersect_plane_plane method is used to compute the intersection of two planes. |
Syntax: |
line = Geom.intersect_plane_plane plane1, plane2 |
Arguments: |
plane1, plane2 - planes |
Return Value: |
line - a line where the planes intersect if successful. Returns nil if the planes do not intersect. |
Comments: |
|
Example: |
# This is really the normal which follows
the x axis. The plane is |
linear_combination |
The linear_combination method is used to compute the linear combination of points or vectors. |
Syntax: |
point = Geom.linear_combination(weight1, point1, weight2, point2) vector = Geom.linear_combination(weight1, vector1, weight2, vector2) |
Arguments: |
weight1 - a weight or percentage point1 - the start point on the line weight2 - a weight or percentage point2 - the end point of the line vector1 - the first vector vector2 - the end point of the line |
Return Value: |
point - point - a Point3d object vector - vector - a Vector3d object |
Comments: |
|
Example: |
point1 = Geom::Point3d.new 1,1,1 |
point_in_polygon_2D |
The point_to_polygon_2D method is used to determine whether a point is inside a polygon when that point is projected as though it and the polygon were in 2D space. The Z component is ignored. |
Syntax: |
status = Geom.point_to_polygon_2D point, points, |
Arguments: |
point - a Point3d object points - an array of points that represent the points of the polygon you are checking border - true if a point on the border is counted as inside the polygon. |
Return Value: |
status - true if the point is inside the polygon. False if the point is not inside the polygon. |
Comments: |
|
Example: |
|