Class: Numerix::Vector4

Inherits:
VectorBase show all
Defined in:
lib/numerix/vector4.rb

Overview

A structure encapsulating four single precision floating point values.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Structure

#[], #[]=, #address, #dup, #each, #pack, #ptr, size, unpack

Constructor Details

#initializeVector4 #initialize(xyzw) ⇒ Vector4 #initialize(x, y, z, w) ⇒ Vector4 #initialize(xyz, w) ⇒ Vector4 #initialize(xy, zw) ⇒ Vector4 #initialize(xy, z, w) ⇒ Vector4

Returns a new instance of Vector4.

Overloads:

  • #initializeVector4

    Creates a Vector with the default values of 0.0.

  • #initialize(xyzw) ⇒ Vector4

    Creates a Vector with each component set to a single value.

    Parameters:

    • xyzw (Float)

      The value to set for all components.

  • #initialize(x, y, z, w) ⇒ Vector4

    Creates a Vector with the specified values.

    Parameters:

    • x (Float)

      The X component of the vector.

    • y (Float)

      The Y component of the vector.

    • z (Float)

      The Z component of the vector.

    • w (Float)

      The W component of the vector.

  • #initialize(xyz, w) ⇒ Vector4

    Creates a Vector with the specified values.

    Parameters:

    • xyz (Vector3)

      Vector3 to use for the X, Y, and Z components.

    • w (Float)

      The W component of the vector.

  • #initialize(xy, zw) ⇒ Vector4

    Creates a Vector with the specified values.

    Parameters:

    • xy (Vector2)

      Vector2 to use for the X and Y components.

    • zw (Vector2)

      Vector2 to use for the Z and W components.

  • #initialize(xy, z, w) ⇒ Vector4

    Creates a Vector with the specified values.

    Parameters:

    • xy (Vector2)

      Vector2 to use for the X and Y components.

    • z (Float)

      The Z component of the vector.

    • w (Float)

      The W component of the vector.



59
60
# File 'lib/numerix/vector4.rb', line 59

def initialize(*args)
end

Instance Attribute Details

#wFloat

Returns the W component of the vector.

Returns:

  • (Float)

    the W component of the vector.



21
22
23
# File 'lib/numerix/vector4.rb', line 21

def w
  @w
end

#xFloat

Returns the X component of the vector.

Returns:

  • (Float)

    the X component of the vector.



9
10
11
# File 'lib/numerix/vector4.rb', line 9

def x
  @x
end

#yFloat

Returns the Y component of the vector.

Returns:

  • (Float)

    the Y component of the vector.



13
14
15
# File 'lib/numerix/vector4.rb', line 13

def y
  @y
end

#zFloat

Returns the Z component of the vector.

Returns:

  • (Float)

    the Z component of the vector.



17
18
19
# File 'lib/numerix/vector4.rb', line 17

def z
  @z
end

Class Method Details

.clamp(min, max) ⇒ Vector4 .clamp(min, max) ⇒ Vector4

Returns a vector that is result of clamping a vector between the specified minimum and maximum values.

Overloads:

  • .clamp(min, max) ⇒ Vector4

    Clamps the vector's components between the specified values.

    Parameters:

    • min (Float)

      The minimum value.

    • max (Float)

      The maximum value.

  • .clamp(min, max) ⇒ Vector4

    Clamps the vector's on a component-wise basis between the minimum and maximum values of the specified vectors.

    Parameters:

    • min (Vector4)

      The minimum value.

    • max (Vector4)

      The maximum value.

Returns:

  • (Vector4)

    the result of clamping this vector.



471
472
# File 'lib/numerix/vector4.rb', line 471

def clamp(vector, min, max)
end

.create_norm(x, y, z, w) ⇒ Vector4

Creates and returns a normalized vector from the specified components.

This is more efficient than creating and then normalizing.

Parameters:

  • x (Float)

    The X component of the vector.

  • y (Float)

    The Y component of the vector.

  • z (Float)

    The Z component of the vector.

  • w (Float)

    The W component of the vector.

Returns:

  • (Vector4)

    the newly created normalized vector.



450
451
# File 'lib/numerix/vector4.rb', line 450

def create_norm(x, y, z, w)
end

.lerp(vector1, vector2, amount) ⇒ Vector4

Linearly interpolates between two vectors based on the given weighting.

Parameters:

  • vector1 (Vector4)

    The first source vector.

  • vector2 (Vector4)

    The second source vector.

  • amount (Float)

    Value between 0.0 and 1.0 indicating the weight of the second source vector.

Returns:

  • (Vector4)

    the interpolated vector.



483
484
# File 'lib/numerix/vector4.rb', line 483

def lerp(vector1, vector2, amount)
end

.max(vector, other) ⇒ Vector4 .max(vector, value) ⇒ Vector4

Returns a vector with a maximum set of values.

Overloads:

  • .max(vector, other) ⇒ Vector4

    Returns a vector whose elements are the maximum of each of the pairs of elements in the two source vectors.

    Parameters:

    • vector (Vector4)

      The first source vector.

    • other (Vector4)

      The second source vector.

  • .max(vector, value) ⇒ Vector4

    Returns a vector whose elements are the maximum of each of vector element and the specified value.

    Parameters:

    • vector (Vector4)

      The source vector.

    • value (Float)

      The maximum value.

Returns:

  • (Vector4)

    the maximized vector.



547
548
# File 'lib/numerix/vector4.rb', line 547

def max(vector, other)
end

.min(vector, other) ⇒ Vector4 .min(vector, value) ⇒ Vector4

Returns a vector with a minimum set of values.

Overloads:

  • .min(vector, other) ⇒ Vector4

    Returns a vector whose elements are the minimum of each of the pairs of elements in the two source vectors.

    Parameters:

    • vector (Vector4)

      The first source vector.

    • other (Vector4)

      The second source vector.

  • .min(vector, value) ⇒ Vector4

    Returns a vector whose elements are the minimum of each of vector element and the specified value.

    Parameters:

    • vector (Vector4)

      The source vector.

    • value (Float)

      The minimum value.

Returns:

  • (Vector4)

    the minimized vector.



526
527
# File 'lib/numerix/vector4.rb', line 526

def min(vector, other)
end

.oneVector4

Returns the vector <1.0, 1.0, 1.0, 1.0>.

Returns:

  • (Vector4)

    the vector <1.0, 1.0, 1.0, 1.0>.



416
417
# File 'lib/numerix/vector4.rb', line 416

def one
end

.transform(vector, matrix) ⇒ Vector4 .transform(vector, rotation) ⇒ Vector4

Creates a Vector4 by transforming the specified vector and transformation matrix or quaternion rotation.

Overloads:

  • .transform(vector, matrix) ⇒ Vector4

    Transforms a vector by the given matrix.

    Parameters:

    Returns:

    • (Vector4)

      A transformed vector.

  • .transform(vector, rotation) ⇒ Vector4

    Transforms a vector by the given Quaternion rotation value.

    Parameters:

    Returns:



505
506
# File 'lib/numerix/vector4.rb', line 505

def transform(vector, other)
end

.unit_wVector4

Returns the vector <0.0, 0.0, 0.0, 1.0>.

Returns:

  • (Vector4)

    the vector <0.0, 0.0, 0.0, 1.0>.



436
437
# File 'lib/numerix/vector4.rb', line 436

def unit_w
end

.unit_xVector4

Returns the vector <1.0, 0.0, 0.0, 0.0>.

Returns:

  • (Vector4)

    the vector <1.0, 0.0, 0.0, 0.0>.



421
422
# File 'lib/numerix/vector4.rb', line 421

def unit_x
end

.unit_yVector4

Returns the vector <0.0, 1.0, 0.0, 0.0>.

Returns:

  • (Vector4)

    the vector <0.0, 1.0, 0.0, 0.0>.



426
427
# File 'lib/numerix/vector4.rb', line 426

def unit_y
end

.unit_zVector4

Returns the vector <0.0, 0.0, 1.0, 0.0>.

Returns:

  • (Vector4)

    the vector <0.0, 0.0, 1.0, 0.0>.



431
432
# File 'lib/numerix/vector4.rb', line 431

def unit_z
end

.zeroVector4

Returns the vector <0.0, 0.0, 0.0, 0.0>.

Returns:

  • (Vector4)

    the vector <0.0, 0.0, 0.0, 0.0>.



411
412
# File 'lib/numerix/vector4.rb', line 411

def zero
end

Instance Method Details

#*(scalar) ⇒ Vector4 #*(other) ⇒ Vector4

Vector multiplication.

Overloads:

  • #*(scalar) ⇒ Vector4

    Scalar vector multiplication.

    Parameters:

    • scalar (Float)

      The scalar value.

  • #*(other) ⇒ Vector4

    Multiplies this vector by another.

    Parameters:

    • other (Vector4)

      The source vector to multiply.

Returns:

  • (Vector4)

    the product vector.



371
372
# File 'lib/numerix/vector4.rb', line 371

def *(other)
end

#**(exponent) ⇒ Vector4

Raises the vector to the given power.

Parameters:

  • exponent (Float)

    The power to raise the vector to.

Returns:

  • (Vector4)

    New vector that is result of the operation.



103
104
# File 'lib/numerix/vector4.rb', line 103

def **(exponent)
end

#+(other) ⇒ Vector4

Adds this vector with another.

Parameters:

  • other (Vector4)

    The vector to add.

Returns:

  • (Vector4)

    the sum of the vectors.



346
347
# File 'lib/numerix/vector4.rb', line 346

def +(other)
end

#-(other) ⇒ Vector4

Gets the difference of this vector and another.

Parameters:

  • other (Vector4)

    The vector to subtract.

Returns:

  • (Vector4)

    the difference of the vectors.



354
355
# File 'lib/numerix/vector4.rb', line 354

def -(other)
end

#-@Vector4

Performs unary negation on this vector instance.

Returns:

  • (Vector4)

    the vector with swapped +/- values.



404
405
# File 'lib/numerix/vector4.rb', line 404

def -@
end

#*(scalar) ⇒ Vector4 #*(other) ⇒ Vector4

Vector division.

Overloads:

  • #*(scalar) ⇒ Vector4

    Scalar vector division.

    Parameters:

    • scalar (Float)

      The scalar value.

  • #*(other) ⇒ Vector4

    Divides this vector by another.

    Parameters:

    • other (Vector4)

      The source vector to divide.

Returns:

  • (Vector4)

    the resulting vector.



388
389
# File 'lib/numerix/vector4.rb', line 388

def /(other)
end

#==(other) ⇒ Boolean

Returns flag if this vector instance is equal to the given object.

Parameters:

  • other (Object)

    The object to compare.

Returns:

  • (Boolean)

    true if objects are equal, otherwise false.



397
398
# File 'lib/numerix/vector4.rb', line 397

def ==(other)
end

#absVector4

Returns a vector whose elements are the absolute values of each of this vector's elements.

Returns:

  • (Vector4)

    a vector whose elements are the absolute values of each of this vector's elements.



241
242
# File 'lib/numerix/vector4.rb', line 241

def abs
end

#clamp(min, max) ⇒ Vector4 #clamp(min, max) ⇒ Vector4

Returns a vector that is result of clamping this vector between the specified minimum and maximum values.

Overloads:

  • #clamp(min, max) ⇒ Vector4

    Clamps the vector's components between the specified values.

    Parameters:

    • min (Float)

      The minimum value.

    • max (Float)

      The maximum value.

  • #clamp(min, max) ⇒ Vector4

    Clamps the vector's on a component-wise basis between the minimum and maximum values of the specified vectors.

    Parameters:

    • min (Vector4)

      The minimum value.

    • max (Vector4)

      The maximum value.

Returns:

  • (Vector4)

    the result of clamping this vector.

See Also:



278
279
# File 'lib/numerix/vector4.rb', line 278

def clamp(min, max)
end

#clamp!(min, max) ⇒ Vector4 #clamp!(min, max) ⇒ Vector4

Clamps this vector between the specified minimum and maximum values.

Overloads:

  • #clamp!(min, max) ⇒ Vector4

    Clamps the vector's components between the specified values.

    Parameters:

    • min (Float)

      The minimum value.

    • max (Float)

      The maximum value.

  • #clamp!(min, max) ⇒ Vector4

    Clamps the vector's on a component-wise basis between the minimum and maximum values of the specified vectors.

    Parameters:

    • min (Vector4)

      The minimum value.

    • max (Vector4)

      The maximum value.

Returns:

See Also:



300
301
# File 'lib/numerix/vector4.rb', line 300

def clamp!(min, max)
end

#distance(vector) ⇒ Float

Returns the Euclidean distance between this vector and another.

Parameters:

  • vector (Vector4)

    The point to get distance between.

Returns:

  • (Float)

    the distance.



146
147
# File 'lib/numerix/vector4.rb', line 146

def distance(vector)
end

#distance_squared(vector) ⇒ Float

Returns the squared Euclidean distance between this vector and another.

Parameters:

  • vector (Vector4)

    The point to get distance between.

Returns:

  • (Float)

    the distance squared.



154
155
# File 'lib/numerix/vector4.rb', line 154

def distance_squared(vector)
end

#dot(other) ⇒ Float

Returns the dot product of this vector and another.

Parameters:

  • other (Vector4)

    the source vector to compute dot product of.

Returns:

  • (Float)

    the dot product.



255
256
# File 'lib/numerix/vector4.rb', line 255

def dot(other)
end

#lengthFloat Also known as: magnitude

Returns the length of the vector.

Returns:

  • (Float)

    the length of the vector.



108
109
# File 'lib/numerix/vector4.rb', line 108

def length
end

#length_squaredFloat

Returns the length of the vector squared.

Returns:

  • (Float)

    the length of the vector squared.



115
116
# File 'lib/numerix/vector4.rb', line 115

def length_squared
end

#lerp(vector, amount) ⇒ Vector4

Linearly interpolates between this vector and another based on the given weighting.

Parameters:

  • vector (Vector4)

    The source vector to interpolate between.

  • amount (Float)

    Value between 0.0 and 1.0 indicating the weight of the given vector.

Returns:

  • (Vector4)

    the interpolated vector.

See Also:



184
185
# File 'lib/numerix/vector4.rb', line 184

def lerp(vector, amount)
end

#lerp!(vector, amount) ⇒ self

Linearly interpolates between this vector and another based on the given weighting, altering the values of this vector.

Parameters:

  • vector (Vector4)

    The source vector to interpolate between.

  • amount (Float)

    Value between 0.0 and 1.0 indicating the weight of the given vector.

Returns:

  • (self)

See Also:



198
199
# File 'lib/numerix/vector4.rb', line 198

def lerp!(vector, amount)
end

#mapObject Also known as: collect

See Also:



76
77
# File 'lib/numerix/vector4.rb', line 76

def map
end

#map! {|component| ... } ⇒ self Also known as: collect!

Invokes the given block once for each element of self, replacing the element with the value returned by the block.

The values of the vector are altered without creating a ne object.

Yields:

  • (component)

    Yields a component of the vector to the block.

Yield Parameters:

  • component (Float)

    The yielded component.

Returns:

  • (self)

See Also:



91
92
# File 'lib/numerix/vector4.rb', line 91

def map!
end

#max_valueFloat

Returns the greatest value of the vector's components.

Returns:

  • (Float)

    the greatest value of the vector's components.



137
138
# File 'lib/numerix/vector4.rb', line 137

def max_value
end

#min_valueFloat

Returns the lowest value of the vector's components.

Returns:

  • (Float)

    the lowest value of the vector's components.



132
133
# File 'lib/numerix/vector4.rb', line 132

def min_value
end

#normalizeVector4

Returns a new vector with the same direction as the given vector, but with a length of 1.0.

Returns:

  • (Vector4)

    a normalized vector.



162
163
# File 'lib/numerix/vector4.rb', line 162

def normalize
end

#normalize!self

Alters this vector instance to maintain same direction, but adjust values so that vector has a length of 1.0.

Returns:

  • (self)


170
171
# File 'lib/numerix/vector4.rb', line 170

def normalize!
end

#one?Boolean

Returns flag indicating if all values of the vector are equal to 1.0.

Returns:

  • (Boolean)

    flag indicating if all values of the vector are equal to 1.0.



121
122
# File 'lib/numerix/vector4.rb', line 121

def one?
end

#sqrtVector4

Returns a vector whose elements are the square root of each of this vector's elements.

Returns:

  • (Vector4)

    a vector whose elements are the square root of each of this vector's elements.



246
247
# File 'lib/numerix/vector4.rb', line 246

def sqrt
end

#to_aArray<Float> Also known as: elements

Returns an Array representation of this instance.

Returns:

  • (Array<Float>)

    an Array representation of this instance.



310
311
# File 'lib/numerix/vector4.rb', line 310

def to_a
end

#to_hHash{Symbol => Float}

Returns a Hash representation of this instance.

Returns:

  • (Hash{Symbol => Float})

    a Hash representation of this instance.



317
318
# File 'lib/numerix/vector4.rb', line 317

def to_h
end

#to_planePlane

Returns a Plane representation of this instance.

Returns:

  • (Plane)

    a Plane representation of this instance.



327
328
# File 'lib/numerix/vector4.rb', line 327

def to_plane
end

#to_quaternionQuaternion

Returns a Quaternion representation of this instance.

Returns:



322
323
# File 'lib/numerix/vector4.rb', line 322

def to_quaternion
end

#to_sString

Returns a String representation of this instance.

Returns:

  • (String)

    a String representation of this instance.



305
306
# File 'lib/numerix/vector4.rb', line 305

def to_s
end

#to_vec2Vector2

Returns a Numerix::Vector2 representation of this instance.

Returns:



332
333
# File 'lib/numerix/vector4.rb', line 332

def to_vec2
end

#to_vec3Vector3

Returns a Numerix::Vector3 representation of this instance.

Returns:



337
338
# File 'lib/numerix/vector4.rb', line 337

def to_vec3
end

#transform(matrix) ⇒ Vector4 #transform(rotation) ⇒ Vector4

Returns a new vector by applying a transformation.

Overloads:

  • #transform(matrix) ⇒ Vector4

    Transforms this vector by the given matrix.

    Parameters:

    • matrix (Matrix4x4)

      the transformation matrix.

  • #transform(rotation) ⇒ Vector4

    Transforms this vector by the specified rotation value.

    Parameters:

    • rotation (Quaternion)

      The rotation to apply.

Returns:

  • (Vector4)

    new transformed vector.

See Also:



217
218
# File 'lib/numerix/vector4.rb', line 217

def transform(other)
end

#transform(matrix) ⇒ self #transform(rotation) ⇒ self

Transforms this vector.

Overloads:

  • #transform(matrix) ⇒ self

    Transforms this vector by the given matrix.

    Parameters:

    • matrix (Matrix4x4)

      the transformation matrix.

  • #transform(rotation) ⇒ self

    Transforms this vector by the specified rotation value.

    Parameters:

    • rotation (Quaternion)

      The rotation to apply.

Returns:

  • (self)

See Also:



236
237
# File 'lib/numerix/vector4.rb', line 236

def transform!(other)
end

#zero?Boolean

Returns flag indicating if all values of the vector are equal to 0.0.

Returns:

  • (Boolean)

    flag indicating if all values of the vector are equal to 0.0.



127
128
# File 'lib/numerix/vector4.rb', line 127

def zero?
end