[ Prev | Index | Next ]
Japanese English

Controlling the Origin Position of a Coordinate System

So far, we've covered how to move coordinate systems by applying incremental displacements relative to their current positions. However, in some cases, you may want to directly specify the position of a coordinate system's origin. This section explains how to do that.

Direct Control of the Origin Position

Setting the Origin Position

To directly set the origin position of a coordinate system, use the setCoordinateLocation(...) function.

- Function Format -

int setCoordinateLocation (
  int coordinateID,
  float x, float y, float z
)

Arguments:

  • coordinateID: The ID of the coordinate system to modify.
  • x, y, z: The X, Y, and Z components of the desired origin position.

Getting the Origin Position

To retrieve the origin position of a coordinate system, use the getCoordinateLocation(...) function.

- Function Format -

int[ ] getCoordinateLocation ( int coordinateID )

The "coordinateID" argument specifies the target coordinate system.

The return value is an array in which:

  • [0] holds the X component,
  • [1] holds the Y component,
  • [2] holds the Z component

of the origin position.

Example Program

Let's try placing a local coordinate system on top of the world coordinate system, and moving it by directly setting its origin position to follow an animated path.

To make the systems easier to distinguish, a smaller axis model is mounted on the local coordinate system, while a larger one is mounted on the world coordinate system.


import graphics3d.Graphics3DFramework;
import Graphics3D;
import Math;  // For using the sin function


// Variable to hold the coordinate system ID
int coord;

// Time counter (in update cycles)
int t = 0;


// Function called at the start of the program
void onStart ( int rendererID ) {

	// Optional screen size and background color settings
	setWindowSize( 800, 600 );
	setBackgroundColor( 0, 0, 0, 255 );


	//  Create a local coordinate system
	coord = newCoordinate( );

	// Mount it on the world coordinate system
	mountCoordinate( coord, rendererID );

	// Place a small axis model on the local coordinate system
	int axis1 = newAxisModel( 1.5, 1.5, 1.5 );
	mountModel( axis1, rendererID, coord );

	// Place a large axis model on the world coordinate system
	int axis2 = newAxisModel( 3.0, 3.0, 3.0 );
	mountModel( axis2, rendererID );
}


// Function called several times per second to update the display
void onUpdate ( int rendererID ) {

	// Move along a Lissajous curve and increment time
	setCoordinateLocation( coord, sin(0.1*t), sin(0.5*t), 0.0 );
	t++;
}
Sample.vcssl

When you run this program, you'll see two axis models on a black screen.

The larger one is mounted on the world coordinate system, while the smaller one is mounted on the local coordinate system. The local coordinate system moves in a complex path, drawing a Lissajous curve.

Execution Result
Execution Result
A large and a small axis model appear. The small coordinate system moves in an animated pattern.


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.