Method: Processing::Vector#initialize

Defined in:
lib/processing/vector.rb

#newVector #new(x) ⇒ Vector #new(x, y) ⇒ Vector #new(x, y, z) ⇒ Vector #new(v) ⇒ Vector #new(a) ⇒ Vector

Initialize vector object.

Parameters:

  • x (Numeric) (defaults to: 0)

    x of vector

  • y (Numeric) (defaults to: 0)

    y of vector

  • z (Numeric) (defaults to: 0)

    z of vector

  • v (Vector)

    vector object to copy

  • a (Array)

    array like [x, y, z]

See Also:



31
32
33
34
35
36
37
38
39
# File 'lib/processing/vector.rb', line 31

def initialize(x = 0, y = 0, z = 0, context: nil)
  @point = case x
    when Rays::Point then x.dup
    when Vector      then x.getInternal__.dup
    when Array       then Rays::Point.new x[0] || 0, x[1] || 0, x[2] || 0
    else                  Rays::Point.new x    || 0, y    || 0, z    || 0
    end
  @context = context || Context.context__
end