Class: Geom::Point3d

Inherits:
Object
show all
Defined in:
lib/point3d.rb

Class Method Summary collapse

• Creates a new point as a linear combination of two points.

Instance Method Summary collapse

• Returns a new point which is offset from the receiver by the given vector.

• Subtracts from this point.

• Compare two points coordinate by coordinate.

• Compare Point3ds using SketchUp tolerance.

• Retrieves the coordinate of the point at the specified index.

• Retrieves the coordinate of the point at the specified index.

• Creates another point identical to the point being cloned.

• Compute the distance from this point to another point.

• Computes the distance from this point to a line.

• Computes the distance from this point to a plane.

• constructor

Creates a new 3D point.

• Returns a string containing a human-readable representation of this point.

• Offsets a point by a vector and returns a new point.

• Applies an offset by a vector to this point.

• Determines if this point is on a line.

• Determines if this point is on a plane.

• Retrieves the point on a line that is closest to this point.

• Retrieves the point on a plane that is closest to this point.

• Sets the values of this point.

• Returns an array representation of this point.

• Returns a string representation of this point.

• Applies a transformation to a copy this point to create a new point.

• Applies a transformation to this point.

• Creates a vector between this point and another point.

• Retrieves the x coordinate of this point.

• Sets the x value of this point.

• Retrieves the y coordinate of this point.

• Sets the y value of this point.

• Retrieves the z coordinate of this point.

• Sets the z value of this point.

Constructor Details

#initialize ⇒ Point3d #initialize(point) ⇒ Point3d #initialize(array) ⇒ Point3d #initialize(x, y, z = 0.0) ⇒ Point3d

Creates a new 3D point.

• #initializePoint3d

Creates a point at the origin with all coordinates set to zero.

• #initialize(point) ⇒ Point3d

Parameters:

• point

another point

• #initialize(array) ⇒ Point3d

Parameters:

• array (Array<Numeric>)

an array of two or three coordinates

• #initialize(x, y, z = 0.0) ⇒ Point3d

Parameters:

• x (Numeric)

the x coordinate

• y (Numeric)

the y coordinate

• z (Numeric) (defaults to: 0.0)

the z coordinate

 15 16 # File 'lib/point3d.rb', line 15 def initialize(*args) end

Class Method Details

.linear_combination(weight1, point1, weight2, point2) ⇒ Geom::Point3d

Creates 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. The weights should sum up to 1 if you want to get a on that line. The weights should be between 0 and 1 if you want to get a point between the two points.

Parameters:

• weight1 (Numeric)

The weight of point1.

• point1
• weight2 (Numeric)

The weight of point2.

• point2

Returns:

 109 110 # File 'lib/point3d.rb', line 109 def self.linear_combination(weight1, point1, weight2, point2) end

Instance Method Details

#+(vector) ⇒ Geom::Point3d

Returns a new point which is offset from the receiver by the given vector.

Examples:

pt = Geom::Point3d.new(1, 2, 3)
pt2 = pt + [1, 1, 1]
==> Point3d(2, 3, 4)

Parameters:

• vector

a Vector3d or Array used to offset the point

Returns:

Since:

• SketchUp 6.0

 26 27 # File 'lib/point3d.rb', line 26 def +(vector) end

#-(vector) ⇒ Geom::Point3d #-(point2) ⇒ Geom::Vector3d

Subtracts from this point.

• #-(vector) ⇒ Geom::Point3d

Returns a point that is offset from this point in the opposite direction of the given vector.

Parameters:

• vector

Returns:

• #-(point2) ⇒ Geom::Vector3d

Returns a vector from another point to this point.

Parameters:

• point2

Returns:

 38 39 # File 'lib/point3d.rb', line 38 def -(vector) end

#<(point2) ⇒ Boolean

Compare two points coordinate by coordinate. First the x coordinates are compared, if they are equal, the y coordinates are compared, if those are equal finally the z coordinates.

Examples:

pt1 = Geom::Point3d.new(10, 10, 90)
pt2 = Geom::Point3d.new(10, 20, 20)
pt1 < pt2 # ==> true

Parameters:

• point2

Returns:

• (Boolean)

true if this point's x, y or z coordinate is less

 49 50 # File 'lib/point3d.rb', line 49 def < (point2) end

#==(point2) ⇒ Boolean

Compare Geom::Point3ds using SketchUp tolerance.

Returns:

• (Boolean)
 55 56 # File 'lib/point3d.rb', line 55 def ==(point2) end

#[](index) ⇒ Numeric

Retrieves the coordinate of the point at the specified index.

Parameters:

• index (Integer)

The index 0, 1 or 2 for a specific x, y, or z value within the point.

Returns:

• (Numeric)

The coordinate at the specified index.

Raises:

• IndexError Raised if the index is outside the range [0,2]. Note that negative indices [-3,-1] don't raise.

 62 63 # File 'lib/point3d.rb', line 62 def [](index) end

#[]=(index, value) ⇒ Numeric

Retrieves the coordinate of the point at the specified index.

Parameters:

• index (Integer)

The index 0, 1 or 2 for a specific x, y, or z value within the point.

• value (Numeric)

The new x, y or z value.

Returns:

• (Numeric)

The argument passed for the new value.

Raises:

• IndexError Raised if the index is outside the range [0,2]. Note that negative indices [-3,-1] don't raise.

 70 71 # File 'lib/point3d.rb', line 70 def []=(index, value) end

#clone ⇒ Geom::Point3d

Creates another point identical to the point being cloned.

Returns:

• A new point that is a copy of this one.

 75 76 # File 'lib/point3d.rb', line 75 def clone end

#distance(point2) ⇒ Length

Compute the distance from this point to another point.

Parameters:

• point2

The Point3d object to compute the distance to.

Returns:

• (Length)

The distance as length object.

 81 82 # File 'lib/point3d.rb', line 81 def distance(point2) end

#distance_to_line(line) ⇒ Length

Computes the distance from this point to a line.

Parameters:

Returns:

• (Length)

The distance as length object.

 87 88 # File 'lib/point3d.rb', line 87 def distance_to_line(line) end

#distance_to_plane(plane) ⇒ Length

Computes the distance from this point to a plane.

Parameters:

• plane

Returns:

• (Length)

The distance as length object.

 93 94 # File 'lib/point3d.rb', line 93 def distance_to_plane(plane) end

#inspect ⇒ String

Returns a string containing a human-readable representation of this point.

Returns:

• (String)

A string representation of the point

 98 99 # File 'lib/point3d.rb', line 98 def inspect end

#offset(vector, length = vector.length) ⇒ Geom::Point3d

Offsets a point by a vector and returns a new point. The length of the vector must not be zero.

Parameters:

• vector

A vector providing direction and distance to offset the point by.

• length (Numeric) (defaults to: vector.length)

The distance to offset. If not provided, the offset is equal to the vector length.

Returns:

• a new Point3d object

 116 117 # File 'lib/point3d.rb', line 116 def offset(vector, length=vector.length) end

#offset!(vector, length = vector.length) ⇒ self

Applies an offset by a vector to this point. The length of the vector must not be zero.

Parameters:

• vector

A vector providing direction and distance to offset the point by.

• length (Numeric) (defaults to: vector.length)

The distance to offset. If not provided, the offset is equal to the vector length.

Returns:

• (self)
 123 124 # File 'lib/point3d.rb', line 123 def offset!(vector, length=vector.length) end

#on_line?(line) ⇒ Boolean

Determines if this point is on a line.

Parameters:

Returns:

• (Boolean)

true if the point is on the line; false if the point is not on the line

 129 130 # File 'lib/point3d.rb', line 129 def on_line?(line) end

#on_plane?(plane) ⇒ Boolean

Determines if this point is on a plane.

Parameters:

• plane

Returns:

• (Boolean)

true if the point is on the plane; false if the point is not on the plane

 135 136 # File 'lib/point3d.rb', line 135 def on_plane?(plane) end

#project_to_line ⇒ Geom::Point3d

Retrieves the point on a line that is closest to this point.

Parameters:

Returns:

• A new point that is on a line closest to the point

 141 142 # File 'lib/point3d.rb', line 141 def project_to_line end

#project_to_plane ⇒ Geom::Point3d

Retrieves the point on a plane that is closest to this point.

Parameters:

• plane

Returns:

• A new point that is on a plane closest to the point

 147 148 # File 'lib/point3d.rb', line 147 def project_to_plane end

#set!(x, y = self.x, z = self.y) ⇒ self

Sets the values of this point.

Parameters:

• x (Numeric)

The location along the x axis.

• y (Numeric) (defaults to: self.x)

The location along the y axis. If not given, this coordinate is not modified.

• z (Numeric) (defaults to: self.y)

The location along the z axis. If not given, this coordinate is not modified.

Returns:

• (self)
 155 156 # File 'lib/point3d.rb', line 155 def set!(x, y=self.x, z=self.y) end

#to_a ⇒ Array(Length,Length,Length)

Returns an array representation of this point.

Returns:

 160 161 # File 'lib/point3d.rb', line 160 def to_a end

#to_s ⇒ String

Returns a string representation of this point.

Returns:

• (String)

A string of this point in the current model units, using the user's locale's decimal delimiter.

 165 166 # File 'lib/point3d.rb', line 165 def to_s end

#transform(transformation) ⇒ Geom::Point3d

Applies a transformation to a copy this point to create a new point.

Parameters:

• transformation

A Transformation object.

Returns:

• The new point

 171 172 # File 'lib/point3d.rb', line 171 def transform(transformation) end

#transform!(transformation) ⇒ self

Applies a transformation to this point. Unlike the #transform method, the point itself is modified.

Parameters:

• transformation

A Transformation object.

Returns:

• (self)
 178 179 # File 'lib/point3d.rb', line 178 def transform!(transformation) end

#vector_to(point2) ⇒ Geom::Vector3d

Creates a vector between this point and another point.

Parameters:

• point2

The other point

Returns:

 184 185 # File 'lib/point3d.rb', line 184 def vector_to(point2) end

#x ⇒ Length

Retrieves the x coordinate of this point.

Returns:

 189 190 # File 'lib/point3d.rb', line 189 def x end

#x=(value) ⇒ Numeric

Sets the x value of this point.

Parameters:

• value (Numeric)

The new x coordinate.

Returns:

• (Numeric)

The argument passed for the new value.

 195 196 # File 'lib/point3d.rb', line 195 def x=(value) end

#y ⇒ Length

Retrieves the y coordinate of this point.

Returns:

 200 201 # File 'lib/point3d.rb', line 200 def y end

#y=(value) ⇒ Numeric

Sets the y value of this point.

Parameters:

• value (Numeric)

The new y coordinate.

Returns:

• (Numeric)

The argument passed for the new value.

 206 207 # File 'lib/point3d.rb', line 206 def y=(value) end

#z ⇒ Length

Retrieves the z coordinate of this point.

Returns:

 211 212 # File 'lib/point3d.rb', line 211 def z end

#z=(value) ⇒ Numeric

Sets the z value of this point.

Parameters:

• value (Numeric)

The new z coordinate.

Returns:

• (Numeric)

The argument passed for the new value.

 217 218 # File 'lib/point3d.rb', line 217 def z=(value) end