Class: Geom::Vector3d
Class Method Summary collapse

.linear_combination(weight1, vector1, weight2, vector2) ⇒ Geom::Vector3d
Creates a new vector as a linear combination of two vectors.
Instance Method Summary collapse

#%(vector) ⇒ Float
Dot product.

#*(vector) ⇒ Geom::Vector3d
Computes the cross product between 2 Vectors.

#+(vector) ⇒ Geom::Vector3d
Vector Addition.

#(vector) ⇒ Geom::Vector3d
Vector subtraction.

#<(vector) ⇒ Boolean
Compare two vectors coordinate by coordinate.

#==(vector) ⇒ Boolean
Compare Vector3ds using SketchUp tolerance.

#[](index) ⇒ Numeric
Retrieves the coordinate of the vector at the specified index.

#[]=(index, value) ⇒ Numeric
Retrieves the coordinate of the vector at the specified index.

#angle_between(vector) ⇒ Float
Compute the angle between this vector and another vector.

#axes ⇒ Array(Geom::Vector3d,Geom::Vector3d,Geom::Vector3d)
Compute an arbitrary set of orthogonal axes with this vector as the zaxis direction.

#clone ⇒ Geom::Vector3d
Creates another vector identical to the vector being cloned.

#cross(vector) ⇒ Geom::Vector3d
Computes the cross product between another vector.

#dot(vector) ⇒ Object
Compute the dot product between another vector.

#initialize(*args) ⇒ Vector3d
constructor
Creates a new 3D vector.

#inspect ⇒ String
Returns a string containing a humanreadable representation of this vector.

#length ⇒ Length
Retrieves the length of this vector.

#length=(value) ⇒ Numeric
Sets length of this vector.

#normalize ⇒ Geom::Vector3d
Creates a copy of this vector that is a unit vector, that means its length is 1.

#normalize! ⇒ self
Modifies this vector into a unit vector, that means this vector's length becomes 1.

#parallel?(vector) ⇒ Boolean
Determines whether this vector is parallel to another vector within tolerance.

#perpendicular?(vector) ⇒ Boolean
Determines whether this vector is perpendicular to another vector within tolerance.

#reverse ⇒ Geom::Vector3d
Creates a copy of this vector in the opposite direction of same length.

#reverse! ⇒ self
Turns this vector in the opposite direction.

#samedirection?(vector) ⇒ Boolean
Determines if this vector is parallel to and in the same direction as another vector to within tolerance.

#set!(x, y = self.x, z = self.y) ⇒ self
Sets the values of this vector.

#to_a ⇒ Array(Length,Length,Length)
Returns an array representation of this vector.

#to_s ⇒ String
Returns a string representation of this vector.

#transform(transformation) ⇒ Geom::Vector3d
Applies a transformation to a copy this vector to create a new vector.

#transform!(transformation) ⇒ self
Applies a transformation to this vector.

#unitvector? ⇒ Boolean
Determines if this vector is a unit vector, that means if its length is 1.0.

#valid? ⇒ Boolean
Verifies if this vector is valid.

#x ⇒ Float
Retrieves the x coordinate of this vector.

#x=(value) ⇒ Numeric
Sets the x value of this vector.

#y ⇒ Float
Retrieves the y coordinate of this vector.

#y=(value) ⇒ Numeric
Sets the y value of this vector.

#z ⇒ Float
Retrieves the z coordinate of this vector.

#z=(value) ⇒ Numeric
Sets the z value of this vector.
Constructor Details
Class Method Details
.linear_combination(weight1, vector1, weight2, vector2) ⇒ Geom::Vector3d
Creates a new vector as a linear combination of two vectors. This method is generally used to get a vector at some percentage along a line connecting the two vectors. 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 vector between the two vectors.
130 131 
# File 'lib/vector3d.rb', line 130 def self.linear_combination(weight1, vector1, weight2, vector2) end 
Instance Method Details
#%(vector) ⇒ Float
Dot product.
21 22 
# File 'lib/vector3d.rb', line 21 def %(vector) end 
#*(vector) ⇒ Geom::Vector3d
Computes the cross product between 2 Vectors. The cross product of two vectors produces a third vector which is perpendicular to the plane in which the first two lie.
29 30 
# File 'lib/vector3d.rb', line 29 def *(vector) end 
#+(vector) ⇒ Geom::Vector3d
Vector Addition
35 36 
# File 'lib/vector3d.rb', line 35 def +(vector) end 
#(vector) ⇒ Geom::Vector3d
Vector subtraction
41 42 
# File 'lib/vector3d.rb', line 41 def (vector) end 
#<(vector) ⇒ Boolean
Compare two vectors 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.
52 53 
# File 'lib/vector3d.rb', line 52 def <(vector) end 
#==(vector) ⇒ Boolean
Compare Geom::Vector3ds using SketchUp tolerance.
58 59 
# File 'lib/vector3d.rb', line 58 def ==(vector) end 
#[](index) ⇒ Numeric
Retrieves the coordinate of the vector at the specified index.
65 66 
# File 'lib/vector3d.rb', line 65 def [](index) end 
#[]=(index, value) ⇒ Numeric
Retrieves the coordinate of the vector at the specified index.
73 74 
# File 'lib/vector3d.rb', line 73 def []=(index, value) end 
#angle_between(vector) ⇒ Float
Compute the angle between this vector and another vector.
79 80 
# File 'lib/vector3d.rb', line 79 def angle_between(vector) end 
#axes ⇒ Array(Geom::Vector3d,Geom::Vector3d,Geom::Vector3d)
Compute an arbitrary set of orthogonal axes with this vector as the zaxis direction. If possible, the vector's xaxis is the up vector, being in plane with the global zaxis.
86 87 
# File 'lib/vector3d.rb', line 86 def axes end 
#clone ⇒ Geom::Vector3d
Creates another vector identical to the vector being cloned.
91 92 
# File 'lib/vector3d.rb', line 91 def clone end 
#cross(vector) ⇒ Geom::Vector3d
Computes the cross product between another vector. The cross product of two vectors produces a third vector which is perpendicular to the plane in which the first two lie.
99 100 
# File 'lib/vector3d.rb', line 99 def cross(vector) end 
#dot(vector) ⇒ Object
Compute the dot product between another vector.
103 104 
# File 'lib/vector3d.rb', line 103 def dot(vector) end 
#inspect ⇒ String
Returns a string containing a humanreadable representation of this vector.
108 109 
# File 'lib/vector3d.rb', line 108 def inspect end 
#length ⇒ Length
Retrieves the length of this vector.
113 114 
# File 'lib/vector3d.rb', line 113 def length end 
#length=(value) ⇒ Numeric
Sets length of this vector.
119 120 
# File 'lib/vector3d.rb', line 119 def length=(value) end 
#normalize ⇒ Geom::Vector3d
Creates a copy of this vector that is a unit vector, that means its length is 1.
135 136 
# File 'lib/vector3d.rb', line 135 def normalize end 
#normalize! ⇒ self
Modifies this vector into a unit vector, that means this vector's length becomes 1.
140 141 
# File 'lib/vector3d.rb', line 140 def normalize! end 
#parallel?(vector) ⇒ Boolean
Determines whether this vector is parallel to another vector within tolerance. The vectors may have different length and be reversed but would still be parallel.
147 148 
# File 'lib/vector3d.rb', line 147 def parallel?(vector) end 
#perpendicular?(vector) ⇒ Boolean
Determines whether this vector is perpendicular to another vector within tolerance.
153 154 
# File 'lib/vector3d.rb', line 153 def perpendicular?(vector) end 
#reverse ⇒ Geom::Vector3d
Creates a copy of this vector in the opposite direction of same length.
158 159 
# File 'lib/vector3d.rb', line 158 def reverse end 
#reverse! ⇒ self
Turns this vector in the opposite direction. This is the same as multiplying its length with 1.
163 164 
# File 'lib/vector3d.rb', line 163 def reverse! end 
#samedirection?(vector) ⇒ Boolean
Determines if this vector is parallel to and in the same direction as another vector to within tolerance.
169 170 
# File 'lib/vector3d.rb', line 169 def samedirection?(vector) end 
#set!(x, y = self.x, z = self.y) ⇒ self
Sets the values of this vector.
177 178 
# File 'lib/vector3d.rb', line 177 def set!(x, y=self.x, z=self.y) end 
#to_a ⇒ Array(Length,Length,Length)
Returns an array representation of this vector.
182 183 
# File 'lib/vector3d.rb', line 182 def to_a end 
#to_s ⇒ String
Returns a string representation of this vector.
187 188 
# File 'lib/vector3d.rb', line 187 def to_s end 
#transform(transformation) ⇒ Geom::Vector3d
Applies a transformation to a copy this vector to create a new vector.
193 194 
# File 'lib/vector3d.rb', line 193 def transform(transformation) end 
#transform!(transformation) ⇒ self
Applies a transformation to this vector. Unlike the #transform method, the vector itself is modified.
200 201 
# File 'lib/vector3d.rb', line 200 def transform!(transformation) end 
#unitvector? ⇒ Boolean
Determines if this vector is a unit vector, that means if its length is 1.0.
205 206 
# File 'lib/vector3d.rb', line 205 def unitvector? end 
#valid? ⇒ Boolean
Verifies if this vector is valid. A vector is valid if its length is not zero.
210 211 
# File 'lib/vector3d.rb', line 210 def valid? end 
#x ⇒ Float
Retrieves the x coordinate of this vector.
215 216 
# File 'lib/vector3d.rb', line 215 def x end 
#x=(value) ⇒ Numeric
Sets the x value of this vector.
221 222 
# File 'lib/vector3d.rb', line 221 def x=(value) end 
#y ⇒ Float
Retrieves the y coordinate of this vector.
226 227 
# File 'lib/vector3d.rb', line 226 def y end 
#y=(value) ⇒ Numeric
Sets the y value of this vector.
232 233 
# File 'lib/vector3d.rb', line 232 def y=(value) end 
#z ⇒ Float
Retrieves the z coordinate of this vector.
237 238 
# File 'lib/vector3d.rb', line 237 def z end 
#z=(value) ⇒ Numeric
Sets the z value of this vector.
243 244 
# File 'lib/vector3d.rb', line 243 def z=(value) end 