Class: Geom::Vector3d

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeVector3d #initialize(vector) ⇒ Vector3d #initialize(array) ⇒ Vector3d #self.new(x, y, z = 0.0) ⇒ Vector3d

Creates a new 3D vector.

Overloads:

  • #initializeVector3d

    Creates a vector with all coordinates set to zero. Note that such a zero-length vector is not valid.

  • #initialize(vector) ⇒ Vector3d

    Parameters:

  • #initialize(array) ⇒ Vector3d

    Parameters:

    • array (Array<Numeric>)

      an array of two or three coordinates

  • #self.new(x, y, z = 0.0) ⇒ Vector3d

    Parameters:

    • x (Numeric)

      the x coordinate

    • y (Numeric)

      the y coordinate

    • z (Numeric) (defaults to: 0.0)

      the z coordinate



15
16
# File 'lib/vector3d.rb', line 15

def initialize(*args)
end

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.

Parameters:

Returns:



130
131
# File 'lib/vector3d.rb', line 130

def self.linear_combination(weight1, vector1, weight2, vector2)
end

Instance Method Details

#%(vector) ⇒ Float

Dot product.

Parameters:

Returns:

  • (Float)


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.

Parameters:

Returns:



29
30
# File 'lib/vector3d.rb', line 29

def *(vector)
end

#+(vector) ⇒ Geom::Vector3d

Vector Addition

Parameters:

Returns:



35
36
# File 'lib/vector3d.rb', line 35

def +(vector)
end

#-(vector) ⇒ Geom::Vector3d

Vector subtraction

Parameters:

Returns:



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.

Examples:

v1 = Geom::Vector3d.new(10, 10, 90)
v2 = Geom::Vector3d.new(10, 20, 20)
v1 < v2 # ==> true

Parameters:

Returns:

  • (Boolean)

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



52
53
# File 'lib/vector3d.rb', line 52

def <(vector)
end

#==(vector) ⇒ Boolean

Compare Geom::Vector3ds using SketchUp tolerance.

Returns:

  • (Boolean)


58
59
# File 'lib/vector3d.rb', line 58

def ==(vector)
end

#[](index) ⇒ Numeric

Retrieves the coordinate of the vector at the specified index.

Parameters:

  • index (Integer)

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

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.



65
66
# File 'lib/vector3d.rb', line 65

def [](index)
end

#[]=(index, value) ⇒ Numeric

Retrieves the coordinate of the vector at the specified index.

Parameters:

  • index (Integer)

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

  • 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.



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.

Parameters:

Returns:

  • (Float)

    The smallest angle between the vectors in radians.



79
80
# File 'lib/vector3d.rb', line 79

def angle_between(vector)
end

#axesArray(Geom::Vector3d,Geom::Vector3d,Geom::Vector3d)

Compute an arbitrary set of orthogonal axes with this vector as the z-axis direction. If possible, the vector's x-axis is the up vector, being in plane with the global z-axis.

Returns:



86
87
# File 'lib/vector3d.rb', line 86

def axes
end

#cloneGeom::Vector3d

Creates another vector identical to the vector being cloned.

Returns:



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.

Parameters:

Returns:



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

#inspectString

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

Returns:

  • (String)

    A string representation of the vector



108
109
# File 'lib/vector3d.rb', line 108

def inspect
end

#lengthLength

Retrieves the length of this vector.

Returns:



113
114
# File 'lib/vector3d.rb', line 113

def length
end

#length=(value) ⇒ Numeric

Sets length of this vector.

Parameters:

  • value (Numeric)

    The new length.

Returns:

  • (Numeric)

    The argument passed for the new value.



119
120
# File 'lib/vector3d.rb', line 119

def length=(value)
end

#normalizeGeom::Vector3d

Creates a copy of this vector that is a unit vector, that means its length is 1.

Returns:



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.

Returns:

  • (self)


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.

Parameters:

Returns:

  • (Boolean)


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.

Parameters:

Returns:

  • (Boolean)


153
154
# File 'lib/vector3d.rb', line 153

def perpendicular?(vector)
end

#reverseGeom::Vector3d

Creates a copy of this vector in the opposite direction of same length.

Returns:



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.

Returns:

  • (self)


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.

Parameters:

Returns:

  • (Boolean)

    true if this vector and vector are in the same direction, false if they are not in the same direction



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.

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)


177
178
# File 'lib/vector3d.rb', line 177

def set!(x, y=self.x, z=self.y)
end

#to_aArray(Length,Length,Length)

Returns an array representation of this vector.

Returns:



182
183
# File 'lib/vector3d.rb', line 182

def to_a
end

#to_sString

Returns a string representation of this vector.

Returns:

  • (String)

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



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.

Parameters:

Returns:



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.

Parameters:

Returns:

  • (self)


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.

Returns:

  • (Boolean)

    true if the vector is a unit vector, false if it is not a unit vector.



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.

Returns:

  • (Boolean)

    true if the vector is valid, false if it is not valid



210
211
# File 'lib/vector3d.rb', line 210

def valid?
end

#xFloat

Retrieves the x coordinate of this vector.

Returns:

  • (Float)


215
216
# File 'lib/vector3d.rb', line 215

def x
end

#x=(value) ⇒ Numeric

Sets the x value of this vector.

Parameters:

  • value (Numeric)

    The new x coordinate.

Returns:

  • (Numeric)

    The argument passed for the new value.



221
222
# File 'lib/vector3d.rb', line 221

def x=(value)
end

#yFloat

Retrieves the y coordinate of this vector.

Returns:

  • (Float)


226
227
# File 'lib/vector3d.rb', line 226

def y
end

#y=(value) ⇒ Numeric

Sets the y value of this vector.

Parameters:

  • value (Numeric)

    The new y coordinate.

Returns:

  • (Numeric)

    The argument passed for the new value.



232
233
# File 'lib/vector3d.rb', line 232

def y=(value)
end

#zFloat

Retrieves the z coordinate of this vector.

Returns:

  • (Float)


237
238
# File 'lib/vector3d.rb', line 237

def z
end

#z=(value) ⇒ Numeric

Sets the z value of this vector.

Parameters:

  • value (Numeric)

    The new z coordinate.

Returns:

  • (Numeric)

    The argument passed for the new value.



243
244
# File 'lib/vector3d.rb', line 243

def z=(value)
end