Class: Geom::Vector3d
- Inherits:
-
Object
- Object
- Geom::Vector3d
- Defined in:
- lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb
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 Vector3d.linear_combination method is used to create a new vector as a linear combination of other vectors.
Instance Method Summary collapse
-
#%(vector) ⇒ Float
The #% method is used to compute the dot product between two vectors.
-
#*(vector) ⇒ Geom::Vector3d
The #* method is used to compute the cross product between two vectors.
-
#+(vector2) ⇒ Geom::Vector3d
The - method is used to add a vector to this one.
-
#-(vector2) ⇒ Geom::Vector3d
The - method is used to subtract a vector from this one.
-
#<(vector2) ⇒ Boolean
The < method is used to determine if a vector’s x, y or z value is less than another vector’s x, y or z value.
-
#==(vector2) ⇒ Boolean
The == method is used to determine if two vectors are equal to within tolerance.
-
#[](i) ⇒ Length
The [] method is used to access the coordinates of a vector as if it was an Array.
-
#[]=(index, value) ⇒ Numeric
The []= method is used to set the coordinates of a vector as if it was an Array.
-
#angle_between(vector2) ⇒ 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(vector) ⇒ Geom::Vector3d
The #cross method is used to compute the cross product between two vectors.
-
#dot(vector) ⇒ Float
The #dot method is used to compute the dot product between two vectors.
-
#initialize(*args) ⇒ Vector3d
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) ⇒ Numeric
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?(vector2) ⇒ Boolean
The parallel method is used to determine if this vector is parallel to another vector to within tolerance.
-
#perpendicular?(vector2) ⇒ Boolean
The perpendicular? method is used to determine if this vector is perpendicular to another vector to within 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?(vector2) ⇒ 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(Length, Length, Length)
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
Apply a Transformation to a vector, returning a new vector.
-
#transform!(transform) ⇒ Geom::Vector3d
Apply 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 ⇒ Length
The x method is used to retrieve the x coordinate of the vector.
-
#x=(x) ⇒ Numeric
The x= method is used to set the x coordinate of the vector.
-
#y ⇒ Length
The y method is used to retrieve the y coordinate of the vector.
-
#y=(y) ⇒ Numeric
Set the y coordinate of the vector.
-
#z ⇒ Length
Get the z coordinate of the vector.
-
#z=(z) ⇒ Numeric
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.
342 343 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 342 def initialize(*args) end |
Class Method Details
.linear_combination(weight1, vector1, weight2, vector2) ⇒ Geom::Vector3d .linear_combination(x, xaxis, y, yaxis, z, zaxis) ⇒ Geom::Vector3d
The 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.
47 48 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 47 def self.linear_combination(*args) end |
Instance Method Details
#%(vector) ⇒ Float
68 69 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 68 def %(vector) end |
#*(vector) ⇒ 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.
96 97 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 96 def *(vector) end |
#+(vector2) ⇒ Geom::Vector3d
The - method is used to add a vector to this one.
112 113 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 112 def +(vector2) end |
#-(vector2) ⇒ Geom::Vector3d
The - method is used to subtract a vector from this one.
128 129 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 128 def -(vector2) end |
#<(vector2) ⇒ Boolean
The < method is used to determine if a vector’s x, y or z value is less than another vector’s x, y or z value.
145 146 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 145 def <(vector2) end |
#==(vector2) ⇒ Boolean
The == method is used to determine if two vectors are equal to within tolerance.
164 165 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 164 def ==(vector2) end |
#[](i) ⇒ 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:
191 192 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 191 def [](i) end |
#[]=(index, value) ⇒ Numeric
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.
209 210 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 209 def []=(index, value) end |
#angle_between(vector2) ⇒ Float
The angle_between method is used to compute the angle (in radians) between this vector and another vector.
226 227 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 226 def angle_between(vector2) end |
#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
243 244 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 243 def axes end |
#clone ⇒ Geom::Vector3d
The clone method is used to make a copy of a vector.
This method is equivalent to vec2 = Geom::Vector3d.new(vec)
258 259 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 258 def clone end |
#cross(vector) ⇒ 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.
284 285 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 284 def cross(vector) end |
#dot(vector) ⇒ Float
The #dot method is used to compute the dot product between two vectors.
301 302 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 301 def dot(vector) end |
#inspect ⇒ Geom::Vector3d
The inspect method is used to inspect the contents of a vector as a friendly string.
356 357 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 356 def inspect end |
#length ⇒ Length
The length method is used to retrieve the length of the vector.
368 369 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 368 def length end |
#length=(length) ⇒ Numeric
The length= method is used to set the length of the vector. The length must be greater than 0.
386 387 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 386 def length=(length) end |
#normalize ⇒ Geom::Vector3d
The normalize method is used to return a vector that is a unit vector of another.
399 400 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 399 def normalize end |
#normalize! ⇒ Geom::Vector3d
The normalize! method is used to convert a vector into a unit vector, in place.
Another way to do this is vec.length = 1
414 415 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 414 def normalize! end |
#parallel?(vector2) ⇒ Boolean
The parallel method is used to determine if this vector is parallel to another vector to within tolerance.
429 430 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 429 def parallel?(vector2) end |
#perpendicular?(vector2) ⇒ Boolean
The perpendicular? method is used to determine if this vector is perpendicular to another vector to within tolerance.
446 447 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 446 def perpendicular?(vector2) end |
#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.
459 460 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 459 def reverse end |
#reverse! ⇒ Geom::Vector3d
The reverse! method is used to reverse the vector in place.
471 472 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 471 def reverse! end |
#samedirection?(vector2) ⇒ 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.
488 489 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 488 def samedirection?(vector2) end |
#set!(array3d) ⇒ Geom::Vector3d #set!(vector) ⇒ Geom::Vector3d #set!(x, y, z) ⇒ Geom::Vector3d
The set! method is used to set the coordinates of the vector.
525 526 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 525 def set!(*args) end |
#to_a ⇒ Array(Length, Length, Length)
The to_a method retrieves the coordinates of the vector in an Array [x, y, z].
537 538 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 537 def to_a end |
#to_s ⇒ String
The to_s method is used to format the vector as a String.
550 551 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 550 def to_s end |
#transform(transform) ⇒ Geom::Vector3d
Apply a Transformation to a vector, returning a new vector. The original vector is unchanged by this method.
565 566 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 565 def transform(transform) end |
#transform!(transform) ⇒ Geom::Vector3d
Apply a Transformation to a vector. The vector itself is modified.
579 580 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 579 def transform!(transform) end |
#unitvector? ⇒ Boolean
The unitvector? method is used to see if the vector is a unit vector.
This is equivalent to vec.length == 1.0
593 594 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 593 def unitvector? end |
#valid? ⇒ Boolean
The valid? method is used to verify if a vector is valid. A vector is valid if its length is not zero.
610 611 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 610 def valid? end |
#x ⇒ Length
The x method is used to retrieve the x coordinate of the vector.
621 622 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 621 def x end |
#x=(x) ⇒ Numeric
The x= method is used to set the x coordinate of the vector.
636 637 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 636 def x=(x) end |
#y ⇒ Length
The y method is used to retrieve the y coordinate of the vector.
648 649 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 648 def y end |
#y=(y) ⇒ Numeric
Set the y coordinate of the vector.
663 664 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 663 def y=(y) end |
#z ⇒ Length
Get the z coordinate of the vector.
675 676 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 675 def z end |
#z=(z) ⇒ Numeric
Set the z coordinate of the vector.
690 691 |
# File 'lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb', line 690 def z=(z) end |