Class: Geom::Point3d
- Inherits:
-
Object
- Object
- Geom::Point3d
- Defined in:
- SketchUp/Geom/Point3d.rb
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 linear_combination method is used to create a new point as a linear combination of two points.
Instance Method Summary collapse
-
#+(point2) ⇒ Geom::Point3d
The ‘+’ operator is a fast way to add to the current x, y and z values of a point, or to set the values of a point by adding to other points together.
-
#-(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) ⇒ Point3d
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(vertex) ⇒ Geom::Point3d #initialize(array2d) ⇒ Geom::Point3d #initialize(input_point) ⇒ Geom::Point3d #initialize(array3d) ⇒ Geom::Point3d
The new method is used to create a new 3D point.
316 317 |
# File 'SketchUp/Geom/Point3d.rb', line 316 def initialize(*args) end |
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.
68 69 |
# File 'SketchUp/Geom/Point3d.rb', line 68 def self.linear_combination(weight1, point1, weight2, point2) end |
Instance Method Details
#+(point2) ⇒ Geom::Point3d
The ‘+’ operator is a fast way to add to the current x, y and z values of a point, or to set the values of a point by adding to other points together.
86 87 |
# File 'SketchUp/Geom/Point3d.rb', line 86 def +(point2) end |
#-(point2) ⇒ Geom::Vector3d
The ‘-’ operator is a fast way to subtract from the current x, y and z values of a point.
102 103 |
# File 'SketchUp/Geom/Point3d.rb', line 102 def -(point2) end |
#<(point2) ⇒ Boolean
The ‘<’ operator is a fast way to determine if another point is closer to the origin.
119 120 |
# File 'SketchUp/Geom/Point3d.rb', line 119 def <(point2) end |
#==(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:
152 153 |
# File 'SketchUp/Geom/Point3d.rb', line 152 def ==(point2) end |
#[](index) ⇒ Length
The [] method is used to retrieve the value of the point at the specified index.
171 172 |
# File 'SketchUp/Geom/Point3d.rb', line 171 def [](index) end |
#[]=(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.
191 192 |
# File 'SketchUp/Geom/Point3d.rb', line 191 def []=(index, new_value) end |
#clone ⇒ Geom::Point3d
The clone method is used to create another point identical to the point being cloned.
204 205 |
# File 'SketchUp/Geom/Point3d.rb', line 204 def clone end |
#distance(point2) ⇒ Length
The distance method is used to compute the distance from a point to another point.
221 222 |
# File 'SketchUp/Geom/Point3d.rb', line 221 def distance(point2) end |
#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.
243 244 |
# File 'SketchUp/Geom/Point3d.rb', line 243 def distance_to_line(line) end |
#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.
263 264 |
# File 'SketchUp/Geom/Point3d.rb', line 263 def distance_to_plane(plane) end |
#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.
332 333 |
# File 'SketchUp/Geom/Point3d.rb', line 332 def inspect end |
#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.
353 354 |
# File 'SketchUp/Geom/Point3d.rb', line 353 def offset(vector, length = vector.length) end |
#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.
376 377 |
# File 'SketchUp/Geom/Point3d.rb', line 376 def offset!(vector, length = vector.length) end |
#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.
396 397 |
# File 'SketchUp/Geom/Point3d.rb', line 396 def on_line?(line) end |
#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.
415 416 |
# File 'SketchUp/Geom/Point3d.rb', line 415 def on_plane?(plane) end |
#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.
435 436 |
# File 'SketchUp/Geom/Point3d.rb', line 435 def project_to_line(line) end |
#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.
457 458 |
# File 'SketchUp/Geom/Point3d.rb', line 457 def project_to_plane(plane) end |
#set!(x, y, z) ⇒ Geom::Point3d #set!(point3d) ⇒ Geom::Point3d #set!(array3d) ⇒ Geom::Point3d
The #set! method is used to set the values of the Point3d.
484 485 |
# File 'SketchUp/Geom/Point3d.rb', line 484 def set!(*args) end |
#to_a ⇒ Array(Length, Length, Length)
The to_a method is used to convert the point to an array of 3 numbers
501 502 |
# File 'SketchUp/Geom/Point3d.rb', line 501 def to_a end |
#to_s ⇒ String
The to_s method is used to retrieve a string representation of a point.
513 514 |
# File 'SketchUp/Geom/Point3d.rb', line 513 def to_s end |
#transform(transform) ⇒ Geom::Point3d
Apply a Transformation to a point, returning a new point. The original vector is unchanged by this method.
531 532 |
# File 'SketchUp/Geom/Point3d.rb', line 531 def transform(transform) end |
#transform!(transform) ⇒ Geom::Point3d
Apply a Transformation to a point. The point itself is modified.
548 549 |
# File 'SketchUp/Geom/Point3d.rb', line 548 def transform!(transform) end |
#vector_to(point2) ⇒ Geom::Vector3d
The vector_to team method retrieves the vector between points.
570 571 |
# File 'SketchUp/Geom/Point3d.rb', line 570 def vector_to(point2) end |
#x ⇒ Length
The x method retrieves the x value of the 3D point.
582 583 |
# File 'SketchUp/Geom/Point3d.rb', line 582 def x end |
#x=(value) ⇒ Numeric
The x= method is used to set the x value of a 3D point.
597 598 |
# File 'SketchUp/Geom/Point3d.rb', line 597 def x=(value) end |
#y ⇒ Length
The y method retrieves the y value of the 3D point.
609 610 |
# File 'SketchUp/Geom/Point3d.rb', line 609 def y end |
#y=(value) ⇒ Numeric
The y= method is used to set the y value of a 3D point.
624 625 |
# File 'SketchUp/Geom/Point3d.rb', line 624 def y=(value) end |
#z ⇒ Length
The z method retrieves the z value of the 3D point.
636 637 |
# File 'SketchUp/Geom/Point3d.rb', line 636 def z end |
#z=(value) ⇒ Numeric
The z= method is used to set the z value of a 3D point.
651 652 |
# File 'SketchUp/Geom/Point3d.rb', line 651 def z=(value) end |