[ 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.

Author of This Article

Fumihiro Matsui
[ Founder of RINEARN, Doctor of Science (Physics), Applied Info Tech Engineer ]
Develops VCSSL, RINEARN Graph 3D and more. Also writes guides and articles.

Translation Cooperator

ChatGPT AIs
[ GPT-3.5, 4, 5, 5.1 ]
We greatly appreciate the cooperation of ChatGPT AIs in translating this article.


Sponsored Link



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

Exevalatorv2.4Released—MCPSupportAdded,NowUsableasanAICalculationTool
2025-11-15 - We'vereleasedExevalatorv2.4,ourexpression-evaluationlibrary.Startingwiththisversion,itsupportsMCP,makingitusableasacalculationtoolforAIassistants.

Exevalatorv2.3Released—NowUsablefromPython
2025-11-04 - We'vereleasedExevalatorv2.3.Startingwiththisversion,youcannowuseitfromPython!WithgrowingdemandaroundAItooldevelopmentinmind,wesharethedetailshere.

ExevalatorUpdated—EasyJapaneseLocalizationforErrorMessages
2025-10-31 - Exevalator2.2.2isout.YoucannowlocalizeerrormessagestoJapanesewithasimplecopy-and-paste,andwe'veincludedseveralbugfixesandminorparseradjustments.

InsideRINPnOnline:ArchitectureOverview
2025-10-22 - AninsidelookatthearchitectureoftherecentlylaunchedonlineversionoftheRINPnscientificcalculator.It'sopensource,soyoucanfreelymodifyandreuseittobuildyourownwebcalculator(maybe!).

MeetRINPnOnline:UsetheScientificCalculatorAnywhere,Instantly
2025-10-21 - RINPn,thefreescientificcalculator,nowhasanonlineversionyoucanuseinstantlyinyourbrowser—onbothPCandsmartphones.Readtheannouncementfordetails.

TheVCSSLSupportAIisHere!—RequiresaChatGPTPlusAccountforPracticalPerformance
2025-08-19 - AnewAIassistantfortheVCSSLprogramminglanguageisheretoansweryourquestionsandhelpwithcoding.ThisarticleexplainshowtouseitandshowcasesplentyofrealQ&Aandgeneratedcodeexamples.

EnglishDocumentationforOurSoftwareandVCSSLIsNowNearlyComplete
2025-06-30 - We'rehappytoannouncethatthelarge-scaleexpansionofourEnglishdocumentationwiththesupportofAI—aprojectthatbegantwoyearsago—hasnowreacheditsinitialtargetmilestone.

VCSSL3.4.52Released:EnhancedIntegrationwithExternalProgramsandMore
2025-05-25 - Thisupdateintroducesenhancementstotheexternalprogramintegrationfeatures(e.g.,forrunningC-languageexecutables).Severalotherimprovementsandfixesarealsoincluded.Detailsinside.