Grasshopper

algorithmic modeling for Rhino

Specific Operators (Addition, Subtraction, Multiplication etc.)

In earlier versions of Grasshopper there were separate components for adding and subtracting vectors, colours, numbers, complex numbers etc. These have mostly disappeared since the regular addition/subtraction/division/multiplication components handle all sensible types and combinations. Here's an exhaustive list of all the functionality of the operator components.

Note that booleans are typically treated as integers (False=0, True=1). Also when two operands of different types are provided (say, Integer and Number, or Number and Complex) then the simpler one is usually upcasted to the more complex one. Thus Integers become floats and floats become complex numbers respectively).

Addition:

  • Integer+Integers returns another integer or a floating point number if the result exceeds the integer range (-2147483648 to +2147483647).
  • Number+Number returns another float.
  • Point+Point returns another point, where the x, y and z components are added together.
  • Vector+Vector returns another vector, where the x, y and z components are added together.
  • Vector+Point returns another point, which is the original point moved along the vector.
  • Complex+Complex returns another complex number which is the sum of the original two.
  • Colour+Colour returns another colour where all channels have been added together. Think of colour addition as shining two flashlights with different colours on the same spot.

Subtraction:

  • Works in the exact opposite way of Addition.

Multiplication:

  • Integer*Integers returns another integer or a floating point number if the result exceeds the integer range (-2147483648 to +2147483647).
  • Number*Number returns another float.
  • Vector*Vector returns the inner-product (or dot product) of the two vectors.
  • Point*Point treats both points as vectors.
  • Point*Vector or Vector*Point again treats the point as a vector.
  • Point*Number returns another point where the x,y and z components are all multiplied by the number.
  • Vector*Number returns another vector where the x,y and z components are all multiplied by the number.
  • Complex*Complex returns a complex number which is the complex product of the two operands.
  • Colour*Colour returns another colour which is the product of both operands. Think of colour multiplication as looking at one colour through a coloured filter.
  • Colour*Number multiplies all channels with the factor.

Division:

  • Similar to Multiplication, except Point/Point and Vector/Vector is not defined.

If you try to operate on a combination types that is undefined, an error should be displayed on the component in question.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Views: 4856

Replies to This Discussion

Great,

Thanks a lot David.

Best

Stephanie

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service