---
name: "SbVec2s"
section: "3"
platform: "linux"
package: "coin"
version: "1:4.0.10-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/SbVec2s"
---

# SbVec2s(3)

The SbVec2s class is a 2 dimensional vector with short integer coordinates.

## NAME

SbVec2s - The **SbVec2s** class is a 2 dimensional vector with short integer coordinates.

## SYNOPSIS

\#include \<Inventor/SbVec2s.h\>

### Public Member Functions

**SbVec2s** (void)\
 **SbVec2s** (const short v\[2\])\
 **SbVec2s** (short x, short y)\
 **SbVec2s** (const **SbVec2us** &v)\
 **SbVec2s** (const **SbVec2b** &v)\
 **SbVec2s** (const **SbVec2i32** &v)\
 **SbVec2s** (const **SbVec2f** &v)\
 **SbVec2s** (const **SbVec2d** &v)\
 **SbVec2s** & **setValue** (const short v\[2\])\
 **SbVec2s** & **setValue** (short x, short y)\
 **SbVec2s** & **setValue** (const **SbVec2us** &v)\
 **SbVec2s** & **setValue** (const **SbVec2b** &v)\
 **SbVec2s** & **setValue** (const **SbVec2i32** &v)\
 **SbVec2s** & **setValue** (const **SbVec2f** &v)\
 **SbVec2s** & **setValue** (const **SbVec2d** &v)\
 const short \* **getValue** (void) const\
 void **getValue** (short &x, short &y) const\
 short & **operator\[\]** (int i)\
 const short & **operator\[\]** (int i) const\
 int32\_t **dot** (**SbVec2s** v) const\
 void **negate** (void)\
 **SbVec2s** & **operator\*=** (int d)\
 **SbVec2s** & **operator\*=** (double d)\
 **SbVec2s** & **operator/=** (int d)\
 **SbVec2s** & **operator/=** (double d)\
 **SbVec2s** & **operator+=** (**SbVec2s** v)\
 **SbVec2s** & **operator-=** (**SbVec2s** v)\
 **SbVec2s** **operator-** (void) const\
 **SbString** **toString** () const\
 SbBool **fromString** (const **SbString** &str)\
 void **print** (FILE \*fp) const\

### Protected Attributes

short **vec** \[2\]\

### Related Symbols

(Note that these are not member symbols.)  **SbVec2s** **operator\*** (const **SbVec2s** &v, int d)\
 **SbVec2s** **operator\*** (const **SbVec2s** &v, double d)\
 **SbVec2s** **operator\*** (int d, const **SbVec2s** &v)\
 **SbVec2s** **operator\*** (double d, const **SbVec2s** &v)\
 **SbVec2s** **operator/** (const **SbVec2s** &v, int d)\
 **SbVec2s** **operator/** (const **SbVec2s** &v, double d)\
 **SbVec2s** **operator+** (const **SbVec2s** &v1, const **SbVec2s** &v2)\
 **SbVec2s** **operator-** (const **SbVec2s** &v1, const **SbVec2s** &v2)\
 int **operator==** (const **SbVec2s** &v1, const **SbVec2s** &v2)\
 int **operator!=** (const **SbVec2s** &v1, const **SbVec2s** &v2)\

## Detailed Description

The **SbVec2s** class is a 2 dimensional vector with short integer coordinates.

This vector class is used by many other classes in Coin. It provides storage for a vector in 2 dimensions as well as simple integer arithmetic operations.

**See also**

**SbVec2f**, **SbVec2d**, **SbVec3s**, **SbVec3f**, **SbVec3d**, **SbVec4f**, **SbVec4d**.

## Constructor & Destructor Documentation

### SbVec2s::SbVec2s (void ) \[inline\]

The default constructor does nothing. The vector coordinates will be uninitialized until you do a **setValue()**.

### SbVec2s::SbVec2s (const short v\[2\]) \[inline\]

Constructs an **SbVec2s** instance with initial values from *v*.

### SbVec2s::SbVec2s (short x, short y) \[inline\]

Constructs an **SbVec2s** instance with the initial vector endpoints from *x* and *y*.

### SbVec2s::SbVec2s (const SbVec2us & v) \[inline\], \[explicit\]

Constructs an **SbVec2s** instance from the value in an **SbVec2us** instance.

**Since**

Coin 2.5

### SbVec2s::SbVec2s (const SbVec2b & v) \[inline\], \[explicit\]

Constructs an **SbVec2s** instance from the value in an **SbVec2b** instance.

**Since**

Coin 2.5

### SbVec2s::SbVec2s (const SbVec2i32 & v) \[inline\], \[explicit\]

Constructs an **SbVec2s** instance from the value in an **SbVec2i32** instance.

**Since**

Coin 2.5

### SbVec2s::SbVec2s (const SbVec2f & v) \[inline\], \[explicit\]

Constructs an **SbVec2s** instance from the value in an **SbVec2f** instance.

**Since**

Coin 2.5

### SbVec2s::SbVec2s (const SbVec2d & v) \[inline\], \[explicit\]

Constructs an **SbVec2s** instance from the value in an **SbVec2d** instance.

**Since**

Coin 2.5

## Member Function Documentation

### SbVec2s & SbVec2s::setValue (const short v\[2\]) \[inline\]

Set new x and y coordinates for the vector from *v*. Returns reference to self.

**See also**

**getValue()**.

### SbVec2s & SbVec2s::setValue (short x, short y) \[inline\]

Set new x and y coordinates for the vector. Returns reference to self.

**See also**

**getValue()**.

### SbVec2s & SbVec2s::setValue (const SbVec2us & v)

**Since**

Coin 2.5

### SbVec2s & SbVec2s::setValue (const SbVec2b & v)

**Since**

Coin 2.5

### SbVec2s & SbVec2s::setValue (const SbVec2i32 & v)

**Since**

Coin 2.5

### SbVec2s & SbVec2s::setValue (const SbVec2f & v)

**Since**

Coin 2.5

### SbVec2s & SbVec2s::setValue (const SbVec2d & v)

**Since**

Coin 2.5

### const short \* SbVec2s::getValue (void ) const \[inline\]

Returns a pointer to an array of two floats containing the x and y coordinates of the vector.

**See also**

**setValue()**.

### void SbVec2s::getValue (short & x, short & y) const \[inline\]

Returns the x and y coordinates of the vector.

**See also**

**setValue()**.

### short & SbVec2s::operator\[\] (int i) \[inline\]

Index operator. Returns modifiable x or y coordinate.

**See also**

**getValue()** and **setValue()**.

### const short & SbVec2s::operator\[\] (int i) const \[inline\]

Index operator. Returns x or y coordinate.

**See also**

**getValue()**.

### int32\_t SbVec2s::dot (SbVec2s v) const \[inline\]

Calculates and returns the result of taking the dot product of this vector and *v*.

### void SbVec2s::negate (void ) \[inline\]

Negate the vector (i.e. point it in the opposite direction).

### SbVec2s & SbVec2s::operator\*= (int d) \[inline\]

Multiply components of vector with value *d*. Returns reference to self.

### SbVec2s & SbVec2s::operator\*= (double d)

Multiply components of vector with value *d*. Returns reference to self.

### SbVec2s & SbVec2s::operator/= (int d) \[inline\]

Divides components of vector with value *d*. Returns reference to self.

### SbVec2s & SbVec2s::operator/= (double d) \[inline\]

Divides components of vector with value *d*. Returns reference to self.

### SbVec2s & SbVec2s::operator+= (SbVec2s v) \[inline\]

Adds this vector and vector *v*. Returns reference to self.

### SbVec2s & SbVec2s::operator-= (SbVec2s v) \[inline\]

Subtracts vector *v* from this vector. Returns reference to self.

### SbVec2s SbVec2s::operator- (void ) const \[inline\]

Non-destructive negation operator. Returns a new **SbVec2s** instance which points in the opposite direction of this vector.

**See also**

**negate()**.

### SbString SbVec2s::toString () const

Return a string representation of this object

### SbBool SbVec2s::fromString (const SbString & str)

Convert from a string representation, return whether this is a valid conversion

### void SbVec2s::print (FILE \* fp) const

Dump the state of this object to the *fp* file stream. Only works in debug version of library, method does nothing in an optimized build.

## Friends And Related Symbol Documentation

### SbVec2s operator\* (const SbVec2s & v, int d) \[related\]

Returns an **SbVec2s** instance which is the components of vector *v* multiplied with *d*.

### SbVec2s operator\* (const SbVec2s & v, double d) \[related\]

Returns an **SbVec2s** instance which is the components of vector *v* multiplied with *d*.

### SbVec2s operator\* (int d, const SbVec2s & v) \[related\]

Returns an **SbVec2s** instance which is the components of vector *v* multiplied with *d*.

### SbVec2s operator\* (double d, const SbVec2s & v) \[related\]

Returns an **SbVec2s** instance which is the components of vector *v* multiplied with *d*.

### SbVec2s operator/ (const SbVec2s & v, int d) \[related\]

Returns an **SbVec2s** instance which is the components of vector *v* divided on *d*.

### SbVec2s operator/ (const SbVec2s & v, double d) \[related\]

Returns an **SbVec2s** instance which is the components of vector *v* divided on *d*.

### SbVec2s operator+ (const SbVec2s & v1, const SbVec2s & v2) \[related\]

Returns an **SbVec2s** instance which is the sum of vectors *v1* and *v2*.

### SbVec2s operator- (const SbVec2s & v1, const SbVec2s & v2) \[related\]

Returns an **SbVec2s** instance which is vector *v2* subtracted from vector *v1*.

### int operator== (const SbVec2s & v1, const SbVec2s & v2) \[related\]

Returns *1* if *v1* and *v2* are equal, *0* otherwise.

### int operator!= (const SbVec2s & v1, const SbVec2s & v2) \[related\]

Returns *1* if *v1* and *v2* are not equal, *0* if they are equal.

## Author

Generated automatically by Doxygen for Coin from the source code.
