Class: Geom::Point3d
- Inherits:
-
Object
- Object
- Geom::Point3d
Overview
The Point3d class allows you to work with a point in 3D space. The point is basically just a series of values representing x, y and z coordinates.
The values are specified as [x,y,z]. For example [100,200,300]. To create a point call Geom::Point3d.new, where the creation method can take a variety of arguments:
In addition to the methods below, there are a series of geometry related methods that are on the Array class, since Point3d objects can also be represented as a 3-element Array. These Array-level methods are for operations such as determining if a point is on a line, on a plane, etc. See the Array class for details.
Class Method Summary # collapse
-
.linear_combination(weight1, point1, weight2, point2) ⇒ Geom::Point3d
The Point3d.linear_combination method is used to create a new point as a linear combination of two points.
Instance Method Summary # collapse
-
#+(vector) ⇒ Geom::Point3d
The #+ operator is a fast way to add to the current x, y and z values of a vector.
-
#-(point2) ⇒ Geom::Vector3d
The '-' operator is a fast way to subtract from the current x, y and z values of a point.
-
#<(point2) ⇒ Boolean
The '<' operator is a fast way to determine if another point is closer to the origin.
-
#==(point2) ⇒ Boolean
The == method is used to compare two points for equality.
-
#[](index) ⇒ Length
The [] method is used to retrieve the value of the point at the specified index.
-
#[]=(index, new_value) ⇒ Numeric
The []= method is used to set the x, y, or z value of the point based on the specific index of the value.
-
#clone ⇒ Geom::Point3d
The clone method is used to create another point identical to the point being cloned.
-
#distance(point2) ⇒ Length
The distance method is used to compute the distance from a point to another point.
-
#distance_to_line(line) ⇒ Float
The distance_to_line method is used to compute the distance from a point to a line.
-
#distance_to_plane(plane) ⇒ Float
The distance_to_plane method is used to compute the distance from the point to a plane.
-
#initialize(*args) ⇒ Object
constructor
The new method is used to create a new 3D point.
-
#inspect ⇒ String
The inspect method is used to format a 3D point as a string.
-
#offset(vector, length = vector.length) ⇒ Geom::Point3d
The offset method is used to offset a point by a vector and return a new point.
-
#offset!(vector, length = vector.length) ⇒ Geom::Point3d
The offset! method is used to offset a point by a vector.
-
#on_line?(line) ⇒ Boolean
The on_line? method is used to determine if the point is on a line.
-
#on_plane?(plane) ⇒ Boolean
The on_plane? method is used to determine if the point is on a plane.
-
#project_to_line(line) ⇒ Geom::Point3d
The project_to_line method is used to retrieve the point on a line that is closest to this point.
-
#project_to_plane(plane) ⇒ Geom::Point3d
The project_to_plane method is used to retrieve the point on a plane that is closest to the point.
-
#set!(*args) ⇒ Object
The #set! method is used to set the values of the Point3d.
-
#to_a ⇒ Array(Length, Length, Length)
The to_a method is used to convert the point to an array of 3 numbers.
-
#to_s ⇒ String
The to_s method is used to retrieve a string representation of a point.
-
#transform(transform) ⇒ Geom::Point3d
Apply a Transformation to a point, returning a new point.
-
#transform!(transform) ⇒ Geom::Point3d
Apply a Transformation to a point.
-
#vector_to(point2) ⇒ Geom::Vector3d
The vector_to team method retrieves the vector between points.
-
#x ⇒ Length
The x method retrieves the x value of the 3D point.
-
#x=(value) ⇒ Numeric
The x= method is used to set the x value of a 3D point.
-
#y ⇒ Length
The y method retrieves the y value of the 3D point.
-
#y=(value) ⇒ Numeric
The y= method is used to set the y value of a 3D point.
-
#z ⇒ Length
The z method retrieves the z value of the 3D point.
-
#z=(value) ⇒ Numeric
The z= method is used to set the z value of a 3D point.
Constructor Details
↑ #initialize ⇒ Geom::Point3d #initialize(x, y, z = 0.0) ⇒ Geom::Point3d #initialize(point3d) ⇒ Geom::Point3d #initialize(array3d) ⇒ Geom::Point3d #initialize(array2d) ⇒ Geom::Point3d #initialize(input_point) ⇒ Geom::Point3d #initialize(vertex) ⇒ Geom::Point3d
The new method is used to create a new 3D point.
Class Method Details
↑ .linear_combination(weight1, point1, weight2, point2) ⇒ Geom::Point3d
The linear_combination method is used to create a new point as a linear combination of two points.
This method is generally used to get a point at some percentage along a line connecting the two points.
A linear combination is a standard term for vector math. It is defined as point = weight1 * point1 + weight2 * point2.
Instance Method Details
↑ #+(vector) ⇒ Geom::Point3d
The #+ operator is a fast way to add to the current x, y and z values of a vector.
↑ #-(point2) ⇒ Geom::Vector3d
The '-' operator is a fast way to subtract from the current x, y and z values of a point.
↑ #<(point2) ⇒ Boolean
The '<' operator is a fast way to determine if another point is closer to the origin.
↑ #==(point2) ⇒ Boolean
The == method is used to compare two points for equality.
This uses the standard SketchUp tolerance to determine if two points are the same.
Points can be compared to one another or to an array representing x, y and z coordinates, as in the following examples:
↑ #[](index) ⇒ Length
The [] method is used to retrieve the value of the point at the specified index.
↑ #[]=(index, new_value) ⇒ Numeric
The []= method is used to set the x, y, or z value of the point based on the specific index of the value.
↑ #clone ⇒ Geom::Point3d
The clone method is used to create another point identical to the point being cloned.
↑ #distance(point2) ⇒ Length
The distance method is used to compute the distance from a point to another point.
↑ #distance_to_line(line) ⇒ Float
This function returns a `Float` value, not a `Length`.
The distance_to_line method is used to compute the distance from a point to a line.
See Geom module for how to specify a line.
↑ #distance_to_plane(plane) ⇒ Float
This function returns a `Float` value, not a `Length`.
The distance_to_plane method is used to compute the distance from the point to a plane.
See module Geom for how to specify a plane.
↑ #inspect ⇒ String
The inspect method is used to format a 3D point as a string.
You will not often use these function directly. Instead, they are called automatically when an object is output using a print command like 'puts', which writes to the Ruby console.
↑ #offset(vector, length = vector.length) ⇒ Geom::Point3d
The offset method is used to offset a point by a vector and return a new point. The length of the vector must not be zero.
↑ #offset!(vector, length = vector.length) ⇒ Geom::Point3d
The offset! method is used to offset a point by a vector. The point itself is modified.
Unlike offset, the point itself is modified.
↑ #on_line?(line) ⇒ Boolean
The on_line? method is used to determine if the point is on a line.
See module Geom for the various ways to specify a line.
↑ #on_plane?(plane) ⇒ Boolean
The on_plane? method is used to determine if the point is on a plane.
See module Geom for the various ways to specify a plane.
↑ #project_to_line(line) ⇒ Geom::Point3d
The project_to_line method is used to retrieve the point on a line that is closest to this point.
The line may be defined by either a point and a vector or by two points.
↑ #project_to_plane(plane) ⇒ Geom::Point3d
The project_to_plane method is used to retrieve the point on a plane that is closest to the point.
The plane may be defined by either a point on the plane and a vector perpendicular to the plane or by the coeficients to the plane equation AX + BY + CZ + D = 0. See Geom for details.
↑ #set!(x, y, z) ⇒ Geom::Point3d #set!(array3d) ⇒ Geom::Point3d #set!(point3d) ⇒ Geom::Point3d
The #set! method is used to set the values of the Point3d.
↑ #to_a ⇒ Array(Length, Length, Length)
The to_a method is used to convert the point to an array of 3 numbers
↑ #transform(transform) ⇒ Geom::Point3d
Apply a Transformation to a point, returning a new point. The original vector is unchanged by this method.
↑ #transform!(transform) ⇒ Geom::Point3d
Apply a Transformation to a point. The point itself is modified.
↑ #vector_to(point2) ⇒ Geom::Vector3d
The vector_to team method retrieves the vector between points.