Class: Array
- Inherits:
-
Object
- Object
- Array
Overview
SketchUp added several geometric methods to the standard Array: arrays of length 2 or 3 can be used as Geom::Point3d / Geom::Vector3d using (three numbers as inch coordinates). Reading Array#x returns the original element in the array (an Integer / Float / Length) without wrapping it in a new Length.
Two-dimensional Geom::Vector2d / Geom::Transformation2d are not yet attached; two-element arrays are treated as three-dimensional with z=0, and Array#normalize / Array#offset still return two Floats.
Instance Method Summary # collapse
-
#cross(vector) ⇒ Geom::Vector3d
Treat the array as a vector and compute the cross product with vector.
-
#distance(point) ⇒ Length
Calculate the distance from each array element (point) to the point.
-
#distance_to_line(line) ⇒ Length
Distance to an infinite line. The line is given as [point, vector] / [point, point], or as two separate parameters.
-
#distance_to_plane(plane) ⇒ Length
Distance to the plane. The plane is given as [point, normal], [A, B, C, D], three points, or a split parameter.
-
#dot(vector) ⇒ Float
Compute the dot product with the array treated as a vector and another vector.
-
#normalize ⇒ Array<Float>
Returns a new normalized array (Float inches), unitized and unmodified from the original array. A two-element array still returns two numbers.
-
#normalize! ⇒ Array
Normalize in place, elements changed to Float inches.
-
#offset(vector) ⇒ Array<Float>
Offset the array as points by translating them along the vector. Return a new array. Provide a length to offset by that specific length.
-
#offset!(vector) ⇒ Array
Translates along the vector in place.
-
#on_line?(line) ⇒ Boolean
Returns true if the point lies on an infinite line (within a length tolerance).
-
#on_plane?(plane) ⇒ Boolean
Checks if points are on a plane (within a length tolerance).
-
#project_to_line(line) ⇒ Array<Float>
Project to an infinite line and return a new array.
-
#project_to_plane(plane) ⇒ Array<Float>
Project to plane and return a new array.
-
#transform(transformation) ⇒ Array<Float>
Transform the array as points and return a new array. Does not include Geom::Transformation2d (LayOut, this issue not implemented).
-
#transform!(transformation) ⇒ Array
Treats the array as a point and transforms it in place.
-
#vector_to(point) ⇒ Geom::Vector3d
Returns the vector from this array (as a point) to point. For a two-element array, assumes z=0; returns Geom::Vector3d, no Vector2d.
-
#x ⇒ Object, nil
The 0th element (X). An empty array is nil, and it does not change the type.
-
#x= ⇒ Object
Set X (index 0), extend the array if necessary.
-
#y ⇒ Object, nil
Returns the element at index 1 (Y), or nil if the array has fewer than two elements.
-
#y= ⇒ Object
Set Y (index 1).
-
#z ⇒ Object, nil
Returns the element at index 2 (Z), or nil if the array has fewer than three elements.
-
#z= ⇒ Object
Set Z (index 2), expanding the two-element array into three elements.
Instance Method Details
array.cross(vector) ⇒ Geom::Vector3d
Treat the array as a vector and compute the cross product with vector.
array.distance(point) ⇒ Length
Calculate the distance from each array element (point) to the point.
array.distance_to_line(line) ⇒ Lengtharray.distance_to_line(point, vector) ⇒ Length
Distance to an infinite line. The line is given as [point, vector] / [point, point], or as two separate parameters.
array.distance_to_plane(plane) ⇒ Lengtharray.distance_to_plane(point, vector) ⇒ Lengtharray.distance_to_plane(p1, p2, p3) ⇒ Lengtharray.distance_to_plane(a, b, c, d) ⇒ Length
Distance to the plane. The plane is given as [point, normal], [A, B, C, D], three points, or a split parameter.
array.dot(vector) ⇒ Float
Compute the dot product with the array treated as a vector and another vector.
array.normalize ⇒ Array<Float>
Returns a new normalized array (Float inches), unitized and unmodified from the original array. A two-element array still returns two numbers.
array.normalize! ⇒ self
Normalize in place, elements changed to Float inches.
array.offset(vector) ⇒ Array<Float>array.offset(vector, length) ⇒ Array<Float>
Offset the array as points by translating them along the vector. Return a new array. Provide a length to offset by that specific length.
array.offset!(vector) ⇒ selfarray.offset!(vector, length) ⇒ self
Translates along the vector in place.
array.on_line?(line) ⇒ Booleanarray.on_line?(point, vector) ⇒ Boolean
Returns true if the point lies on an infinite line (within a length tolerance).
array.on_plane?(plane) ⇒ Booleanarray.on_plane?(point, vector) ⇒ Booleanarray.on_plane?(p1, p2, p3) ⇒ Booleanarray.on_plane?(a, b, c, d) ⇒ Boolean
Checks if points are on a plane (within a length tolerance).
array.project_to_line(line) ⇒ Array<Float>array.project_to_line(point, vector) ⇒ Array<Float>
Project to an infinite line and return a new array.
array.project_to_plane(plane) ⇒ Array<Float>array.project_to_plane(point, vector) ⇒ Array<Float>
Project to plane and return a new array.
array.transform(transformation) ⇒ Array<Float>
Transform the array as points and return a new array. Does not include Geom::Transformation2d (LayOut, this issue not implemented).
array.transform!(transformation) ⇒ self
Treats the array as a point and transforms it in place.
array.vector_to(point) ⇒ Geom::Vector3d
Returns the vector from this array (as a point) to point. For a two-element array, assumes z=0; returns Geom::Vector3d, no Vector2d.
array.x ⇒ Object, nil
The 0th element (X). An empty array is nil, and it does not change the type.
array.x = value ⇒ value
Set X (index 0), extend the array if necessary.
array.y ⇒ Object, nil
Returns the element at index 1 (Y), or nil if the array has fewer than two elements.
array.y = value ⇒ value
Set Y (index 1).
array.z ⇒ Object, nil
Returns the element at index 2 (Z), or nil if the array has fewer than three elements.
array.z = value ⇒ value
Set Z (index 2), expanding the two-element array into three elements.