Class SbVec2f

java.lang.Object
com.openinventor.inventor.SbBasic
com.openinventor.inventor.SbVec2f

public class SbVec2f extends SbBasic
2D vector class. 2D vector class used to store 2D vectors and points. This class is used throughout Open Inventor for arguments and return values.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final float[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    SbVec2f(float val)
    Constructor that sets all components to the same value.
    SbVec2f(float[] components)
     
    SbVec2f(float c0, float c1)
     
    SbVec2f(SbVec2f copyFrom)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Component-wise vector addition operator.
    void
    divide(float d)
    Component-wise scalar division operator.
    float
    Returns dot (inner) product of vector and another vector.
    boolean
    equals(SbVec2f v, float tolerance)
    Equality comparison within given tolerance - the square of the length of the maximum distance between the two vectors.
    boolean
     
    float[]
     
    float
    getValueAt(int index)
     
    float
     
    float
     
    float
    Returns geometric length of vector.
    float
    Returns square length of vector.
    Component-wise binary vector subtraction operator.
    void
    multiply(float d)
    Component-wise scalar multiplication operator.
    void
    Component-wise vector multiplication operator.
    void
    Negates each component of vector in place.
    float
    Changes vector to be unit length.
    over(float d)
    Component-wise binary scalar division operator.
    Component-wise binary vector addition operator.
    setValue(float[] components)
     
    setValue(float[] components, int startIndex)
     
    setValue(float c0, float c1)
     
    Sets value of vector from a double precision vector.
    void
    setValue(SbVec2f copyFrom)
     
    void
    setValueAt(int index, float value)
     
    void
    setX(float value)
     
    void
    setY(float value)
     
    void
    Component-wise vector subtraction operator.
    times(float d)
    Component-wise binary scalar multiplication operator.
    Component-wise vector multiplication operator.
    static SbVec2f[]
    toArray(long nativeArray, long length)
     

    Methods inherited from class java.lang.Object

    getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • array

      public final float[] array
  • Constructor Details

    • SbVec2f

      public SbVec2f()
    • SbVec2f

      public SbVec2f(float c0, float c1)
    • SbVec2f

      public SbVec2f(float[] components)
    • SbVec2f

      public SbVec2f(SbVec2f copyFrom)
    • SbVec2f

      public SbVec2f(float val)
      Constructor that sets all components to the same value.
  • Method Details

    • setX

      public void setX(float value)
    • setValue

      public void setValue(SbVec2f copyFrom)
    • setValue

      public SbVec2f setValue(float c0, float c1)
    • setValueAt

      public void setValueAt(int index, float value)
    • getValue

      public float[] getValue()
    • setValue

      public SbVec2f setValue(float[] components, int startIndex)
    • getValueAt

      public float getValueAt(int index)
    • setValue

      public SbVec2f setValue(float[] components)
    • getY

      public float getY()
    • setY

      public void setY(float value)
    • getX

      public float getX()
    • over

      public SbVec2f over(float d)
      Component-wise binary scalar division operator.
    • toArray

      public static SbVec2f[] toArray(long nativeArray, long length)
    • minus

      public SbVec2f minus(SbVec2f v2)
      Component-wise binary vector subtraction operator.
    • equals

      public boolean equals(SbVec2f v, float tolerance)
      Equality comparison within given tolerance - the square of the length of the maximum distance between the two vectors.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • plus

      public SbVec2f plus(SbVec2f v2)
      Component-wise binary vector addition operator.
    • lengthSquared

      public float lengthSquared()
      Returns square length of vector. Faster than length().
    • length

      public float length()
      Returns geometric length of vector.
    • normalize

      public float normalize()
      Changes vector to be unit length.
    • negate

      public void negate()
      Negates each component of vector in place.
    • dot

      public float dot(SbVec2f v)
      Returns dot (inner) product of vector and another vector.
    • divide

      public void divide(float d)
      Component-wise scalar division operator.
    • multiply

      public void multiply(SbVec2f v)
      Component-wise vector multiplication operator.
    • add

      public void add(SbVec2f u)
      Component-wise vector addition operator.
    • times

      public SbVec2f times(float d)
      Component-wise binary scalar multiplication operator.
    • substract

      public void substract(SbVec2f u)
      Component-wise vector subtraction operator.
    • setValue

      public SbVec2f setValue(SbVec2d vec2d)
      Sets value of vector from a double precision vector. If the values stored in the double precision argument(s) are too large to be stored in single precision variables, some loss of data will occur during the data transfer. The loss of data is defined by the standard C type conversion from double to float. It is the application's responsibility to handle this potential loss of data appropriately.

      NOTE: Open Inventor fields still store only single precision values, not double precision values.

    • times

      public SbVec2f times(SbVec2f v)
      Component-wise vector multiplication operator.
    • multiply

      public void multiply(float d)
      Component-wise scalar multiplication operator.