Class: Geom::Point3d
Relationships | |
Inherits: | Object |
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 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
-
.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.
-
.new ⇒ Geom::Point3d
constructor
The new method is used to create a new 3D point.
Instance Attribute Summary
-
#x ⇒ Length
rw
The x method retrieves the x value of the 3D point.
-
#x=(value) ⇒ Numeric
rw
The x= method is used to set the x value of a 3D point.
-
#y ⇒ Length
rw
The y method retrieves the y value of the 3D point.
-
#y=(value) ⇒ Numeric
rw
The y= method is used to set the y value of a 3D point.
-
#z ⇒ Length
rw
The z method retrieves the z value of the 3D point.
-
#z=(value) ⇒ Numeric
rw
The z= method is used to set the z value of a 3D point.
Instance Method Summary
-
#+(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.
-
#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!(x, y, z) ⇒ 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.
-
#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.
Constructor Details
.new ⇒ Point3d
.new(x, y, z = 0.0) ⇒ Point3d
.new(point3d) ⇒ Point3d
.new(array3d) ⇒ Point3d
.new(array2d) ⇒ Point3d
.new(input_point) ⇒ Point3d
.new(vertex) ⇒ Point3d
Point3d
.new(x, y, z = 0.0) ⇒ Point3d
.new(point3d) ⇒ Point3d
.new(array3d) ⇒ Point3d
.new(array2d) ⇒ Point3d
.new(input_point) ⇒ Point3d
.new(vertex) ⇒ Point3d
The new method is used to create a new 3D point.
Class Method Details
.linear_combination(weight1, point1, weight2, point2) ⇒ 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 Attribute Details
#x ⇒ Length (rw)
The x method retrieves the x value of the 3D point.
#x=(value) ⇒ Numeric (rw)
The x= method is used to set the x value of a 3D point.
#y ⇒ Length (rw)
The y method retrieves the y value of the 3D point.
#y=(value) ⇒ Numeric (rw)
The y= method is used to set the y value of a 3D point.
#z ⇒ Length (rw)
The z method retrieves the z value of the 3D point.
#z=(value) ⇒ Numeric (rw)
The z= method is used to set the z value of a 3D point.
Instance Method Details
#+(vector) ⇒ 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 ⇒ 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
#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) ⇒ 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) ⇒ 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) ⇒ 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) ⇒ 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) ⇒ Point3d
#set!(array3d) ⇒ Point3d
#set!(point3d) ⇒ Point3d
Point3d
#set!(array3d) ⇒ Point3d
#set!(point3d) ⇒ 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
#to_s ⇒ String
The to_s method is used to retrieve a string representation of a point.
#transform(transform) ⇒ Point3d
Apply a Transformation
to a point, returning a new point. The original vector is unchanged by this method.
#transform!(transform) ⇒ 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.