[ Prev | Index | Next ]
Japanese English

Creating, Placing, and Performing Basic Operations on Vectors

This section covers how to create and place vectors, as well as how to perform basic operations on them.

What Is a Vector?

When working in 3D space, it's convenient to treat values in groups of three, like (X, Y, Z).

For example, a position in space is defined by its (X, Y, Z) coordinates. A direction in space is likewise represented by a set of three components (Vx, Vy, Vz), and the displacement of a moving object over a unit of time can be described similarly using (dx, dy, dz).

In this way, a vector is simply a group of three components treated as a single unit in 3D space.

In VCSSL, vectors can be created and placed in coordinate systems, allowing for convenient operations like coordinate transformations, dot products, and cross products.

Creating a Vector

To create a vector, use the newVector(...) function:

- Function Format -

int newVector ( float x, float y, float z )

The arguments x, y, and z specify the X, Y, and Z components of the vector.

This function creates a vector with those components and returns a unique ID assigned to it.

You can also create a copy of an existing vector by passing its ID:

- Function Format -

int newVector ( int copyID )

Placing a Vector

Once created, a vector can be placed into a coordinate system, just like models or polygons. To place a vector, use the mountVector(...) function.

- Function Format -

int mountVector ( int vectorID, int rendererID )
int mountVector ( int vectorID, int rendererID, int coordinateID )

These two variations allow you to:

  • Place the vector in the world coordinate system (first form).
  • Place the vector in any specified coordinate system (second form).

Arguments:

  • vectorID: The ID of the vector to place.
  • rendererID: The ID of the renderer.
  • coordinateID: The ID of the coordinate system to place the vector in (if omitted, it defaults to the world coordinate system).

Setting Vector Components

To set the components of a vector, use the setVector(...) function:

- Function Format -

void setVector ( int vectorID, float x, float y, float z )

Arguments:

  • vectorID: The ID of the vector to modify.
  • x, y, z: The X, Y, and Z components to assign to the vector.

This function updates the components of an existing vector.

Getting Vector Components

To retrieve the components of a vector, use the getVectorX(...), getVectorY(...), and getVectorZ(...) functions:

- Function Format -

float getVectorX ( int vectorID )
float getVectorY ( int vectorID )
float getVectorZ ( int vectorID )

Each function returns the X, Y, or Z component of the vector, respectively.

The "vectorID" argument specifies the target vector.

Dot Product

To calculate the dot product (inner product) of two vectors, use the getVectorInnerProduct(...) function:

- Function Format -

float getVectorInnerProduct ( int vectorID1, int vectorID2 )

Arguments:

  • vectorID1: The ID of the first vector.
  • vectorID2: The ID of the second vector.

This function returns the dot product of the two specified vectors.

Cross Product

To calculate the cross product of two vectors, use the getVectorCrossProduct(...) function:

- Function Format -

void getVectorCrossProduct (
  int vectorID1, int vectorID2, int crossVector
)

Arguments:

  • vectorID1: The ID of the first vector.
  • vectorID2: The ID of the second vector.
  • crossVector: The ID of the vector where the result will be stored. This vector must be created in advance, but its contents will be overwritten by this function, so the initial values don't matter.


Sponsored Link



Japanese English
Index
[ Prev | Index | Next ]
News From RINEARN
* VCSSL is developed by RINEARN.

English Documentation for Our Software and VCSSL Is Now Nearly Complete
2025-06-30 - We're happy to announce that the large-scale expansion of our English documentation with the support of AI — a project that began two years ago — has now reached its initial target milestone.

VCSSL 3.4.52 Released: Enhanced Integration with External Programs and More
2025-05-25 - This update introduces enhancements to the external program integration features (e.g., for running C-language executables). Several other improvements and fixes are also included. Details inside.

Released: Latest Version of VCSSL with Fixes for Behavioral Changes on Java 24
2025-04-22 - VCSSL 3.4.50 released with a fix for a subtle behavioral change in absolute path resolution on network drives, introduced in Java 24. Details inside.

Released the Latest Versions of RINEARN Graph and VCSSL - Now Supporting Customizable Tick Positions and Labels!
2024-11-24 - Starting with this update, a new "MANUAL" tick mode is now supported, allowing users to freely specify the positions and labels of ticks on the graph. We'll explain the details and how to use it.

Released Exevalator 2.2: Now Compatible with TypeScript and Usable in Web Browsers
2024-10-22 - The open-source expression evaluation library, Exevalator, has been updated to version 2.2. It now supports TypeScript and can be used for evaluating expressions directly in web browsers. Explains the details.

Behind the Scenes of Creating an Assistant AI (Part 1: Fundamental Knowledge)
2024-10-07 - The first part of a series on how to create an Assistant AI. In this article, we introduce the essential knowledge you need to grasp before building an Assistant AI. What exactly is an LLM-based AI? What is RAG? And more.

Launching an Assistant AI to Support Software Usage!
2024-09-20 - We've launched an Assistant AI that answers questions about how to use RINEARN software and helps with certain tasks. Anyone with a ChatGPT account can use it for free. We'll explain how to use it.

Software Updates: Command Expansion in RINEARN Graph, and English Support in VCSSL
2024-02-05 - We updated our apps. This updates include "Enhancing the Command-Line Features of RINEARN Graph" and "Adding English Support to VCSSL." Dives into each of them!