Class: Geom::Vector3d
- Inherits:
-
Object
- Object
- Geom::Vector3d
Overview
The Vector3d class is used to represent vectors in a 3 dimensional space. Vectors in SketchUp have a direction and a length, but not a starting point.
There are numerous tutorials on 3D vectors available on the internet.
Class Method Summary # collapse
-
.linear_combination(*args) ⇒ Object
The #linear_combination method is used to create a new vector as a linear combination of other vectors.
Instance Method Summary # collapse
-
#%(vector3d) ⇒ Float
The #% method is used to compute the dot product between two vectors.
-
#*(vector3d) ⇒ Geom::Vector3d
The #* method is used to compute the cross product between two vectors.
-
#+(vector3d) ⇒ Geom::Vector3d
The #+ method is used to add a vector to this one.
-
#-(vector3d) ⇒ Geom::Vector3d
The #- method is used to subtract a vector from this one.
-
#<(vector3d) ⇒ Boolean
The #< compare method is used to compare two vectors to determine if the left-hand vector is less than the right-hand vector.
-
#==(vector3d) ⇒ Boolean
The #== method is used to determine if two vectors are equal to within tolerance.
-
#[](index) ⇒ Length
The #[] method is used to access the coordinates of a vector as if it was an Array.
-
#[]=(index, value) ⇒ Float
The #[]= method is used to set the coordinates of a vector as if it was an Array.
-
#angle_between(vector3d) ⇒ Float
The #angle_between method is used to compute the angle (in radians) between this vector and another vector.
-
#axes ⇒ Array(Geom::Vector3d, Geom::Vector3d, Geom::Vector3d)
The #axes method is used to compute an arbitrary set of axes with the given vector as the z-axis direction.
-
#clone ⇒ Geom::Vector3d
The #clone method is used to make a copy of a vector.
-
#cross(vector3d) ⇒ Geom::Vector3d
The #cross method is used to compute the cross product between two vectors.
-
#dot(vector3d) ⇒ Float
The #dot method is used to compute the dot product between two vectors.
-
#initialize(*args) ⇒ Object
constructor
The new method is used to create a new vector.
-
#inspect ⇒ Geom::Vector3d
The #inspect method is used to inspect the contents of a vector as a friendly string.
-
#length ⇒ Length
The #length method is used to retrieve the length of the vector.
-
#length=(length) ⇒ Length
The #length= method is used to set the length of the vector.
-
#normalize ⇒ Geom::Vector3d
The #normalize method is used to return a vector that is a unit vector of another.
-
#normalize! ⇒ Geom::Vector3d
The #normalize! method is used to convert a vector into a unit vector, in place.
-
#parallel?(vector3d) ⇒ Boolean
The #parallel? method determines if two Vector3ds are parallel within a tolerance.
-
#perpendicular?(vector3d) ⇒ Boolean
The #perpendicular? method determines if two Geom::Vector3ds are perpendicular within a tolerance.
-
#reverse ⇒ Geom::Vector3d
The #reverse method is used to return a new vector that is the reverse of this vector, while leaving the original unchanged.
-
#reverse! ⇒ Geom::Vector3d
The #reverse! method is used to reverse the vector in place.
-
#samedirection?(vector3d) ⇒ Boolean
The #samedirection? method is used to determine if this vector is parallel to and in the same direction as another vector to within tolerance.
-
#set!(*args) ⇒ Object
The #set! method is used to set the coordinates of the vector.
-
#to_a ⇒ Array(Float, Float, Float)
The #to_a method retrieves the coordinates of the vector in an Array[x, y, z].
-
#to_s ⇒ String
The #to_s method is used to format the vector as a String.
-
#transform(transform) ⇒ Geom::Vector3d
The #transform method applies a Transformation to a vector, returning a new vector.
-
#transform!(transform) ⇒ Geom::Vector3d
The #transform! method applies a Transformation to a vector.
-
#unitvector? ⇒ Boolean
The #unitvector? method is used to see if the vector is a unit vector.
-
#valid? ⇒ Boolean
The #valid? method is used to verify if a vector is valid.
-
#x ⇒ Float
The #x method is used to retrieve the x coordinate of the vector.
-
#x=(x) ⇒ Float
The #x= method is used to set the x coordinate of the vector.
-
#y ⇒ Float
The #y method is used to retrieve the y coordinate of the vector.
-
#y=(y) ⇒ Float
Set the #y= coordinate of the vector.
-
#z ⇒ Float
Get the #z coordinate of the vector.
-
#z=(z) ⇒ Float
Set the #z= coordinate of the vector.
Constructor Details
↑ #initialize ⇒ Geom::Vector3d #initialize(x, y, z) ⇒ Geom::Vector3d #initialize(array3d) ⇒ Geom::Vector3d #initialize(array2d) ⇒ Geom::Vector3d #initialize(vector) ⇒ Geom::Vector3d
The new method is used to create a new vector.
Class Method Details
↑ .linear_combination(weight1, vector1, weight2, vector2) ⇒ Geom::Vector3d .linear_combination(x, xaxis, y, yaxis, z, zaxis) ⇒ Geom::Vector3d
The Geom#linear_combination method is used to create a new vector as a linear combination of other vectors. This method is generally used to get a vector at some percentage between two vectors.
A linear combination is a standard term for vector math. It is defined as vector = weight1 * vector1 + weight2 * vector2
Instance Method Details
↑ #%(vector3d) ⇒ Float
↑ #*(vector3d) ⇒ Geom::Vector3d
The #* method is used to compute the cross product between two vectors.
The cross product, also called the vector product, is an operation on two vectors. The cross product of two vectors produces a third vector which is perpendicular to the plane in which the first two lie.
This is an alias of the #cross method.
↑ #+(vector3d) ⇒ Geom::Vector3d
The #+ method is used to add a vector to this one.
↑ #-(vector3d) ⇒ Geom::Vector3d
The #- method is used to subtract a vector from this one.
↑ #<(vector3d) ⇒ Boolean
The #< compare method is used to compare two vectors to determine if the left-hand vector is less than the right-hand vector.
↑ #==(vector3d) ⇒ Boolean
The #== method is used to determine if two vectors are equal to within tolerance.
↑ #[](index) ⇒ Length
The #[] method is used to access the coordinates of a vector as if it was an Array. The index must be 0, 1 or 2.
The following are equivalent:
↑ #[]=(index, value) ⇒ Float
The #[]= method is used to set the coordinates of a vector as if it was an Array. The value of i must be 0, 1 or 2.
↑ #angle_between(vector3d) ⇒ Float
The #angle_between method is used to compute the angle (in radians) between this vector and another vector.
↑ #axes ⇒ Array(Geom::Vector3d, Geom::Vector3d, Geom::Vector3d)
The #axes method is used to compute an arbitrary set of axes with the given vector as the z-axis direction.
Returns an Array of three vectors [xaxis, yaxis, zaxis]
Vector3d objects
↑ #clone ⇒ Geom::Vector3d
The #clone method is used to make a copy of a vector.
↑ #cross(vector3d) ⇒ Geom::Vector3d
The #cross method is used to compute the cross product between two vectors.
The cross product, also called the vector product, is an operation on two vectors. The cross product of two vectors produces a third vector which is perpendicular to the plane in which the first two lie.
↑ #inspect ⇒ Geom::Vector3d
The #inspect method is used to inspect the contents of a vector as a friendly string.
↑ #length=(length) ⇒ Length
The #length= method is used to set the length of the vector. The length must be greater than 0.
↑ #normalize ⇒ Geom::Vector3d
The #normalize method is used to return a vector that is a unit vector of another.
↑ #normalize! ⇒ Geom::Vector3d
The #normalize! method is used to convert a vector into a unit vector, in place.
Another way to do this is vector.length = 1.0
↑ #parallel?(vector3d) ⇒ Boolean
The #parallel? method determines if two Geom::Vector3ds are parallel within a tolerance. Two vectors are parallel if there exists a scalar multiple between them.
↑ #perpendicular?(vector3d) ⇒ Boolean
The #perpendicular? method determines if two Geom::Vector3ds are perpendicular within a tolerance. Two vectors are considered perpendicular if their dot product is zero.
↑ #reverse ⇒ Geom::Vector3d
The #reverse method is used to return a new vector that is the reverse of this vector, while leaving the original unchanged.
↑ #reverse! ⇒ Geom::Vector3d
The #reverse! method is used to reverse the vector in place.
↑ #samedirection?(vector3d) ⇒ Boolean
The #samedirection? method is used to determine if this vector is parallel to and in the same direction as another vector to within tolerance.
↑ #set!(vector) ⇒ Geom::Vector3d #set!(x, y, z) ⇒ Geom::Vector3d #set!(array3d) ⇒ Geom::Vector3d
The #set! method is used to set the coordinates of the vector.
↑ #to_a ⇒ Array(Float, Float, Float)
The #to_a method retrieves the coordinates of the vector in an Array[x, y, z].
↑ #transform(transform) ⇒ Geom::Vector3d
The #transform method applies a Transformation to a vector, returning a new vector. The original vector is unchanged by this method.
↑ #transform!(transform) ⇒ Geom::Vector3d
The #transform! method applies a Transformation to a vector. The vector itself is modified.
↑ #unitvector? ⇒ Boolean
The #unitvector? method is used to see if the vector is a unit vector.
This is equivalent to vector.length == 1.0