[ Prev | Index | Next ]
Japanese English

Rotating a Coordinate System

This section covers how to rotate coordinate systems.

The type of rotation discussed here is based on the axes of the parent coordinate system. For rotations based on the axes of the coordinate system itself, see the next section: Spinning a Coordinate System.

Rotating a Coordinate System

Rotation Around Each Axis

To rotate a coordinate system around one of the parent system's axes (X, Y, or Z), use the rotCoordinateX(...), rotCoordinateY(...), and rotCoordinateZ(...) functions:

- Function Format -

void rotCoordinateX ( int coordinateID, float angle )
void rotCoordinateY ( int coordinateID, float angle )
void rotCoordinateZ ( int coordinateID, float angle )

These three functions handle rotation around the X, Y, and Z axes, respectively.

Arguments:

  • coordinateID: The ID of the coordinate system to rotate.
  • angle: The angle of rotation in radians. Positive rotation is in the direction a right-hand screw would advance along the axis.

What is a radian?
A radian is a unit of angular measure commonly used in science and engineering. In this unit system, 180 degrees is equivalent to π radians. For example, 90 degrees = π/2 radians, and 45 degrees = π/4 radians.
角度とラジアンの対応図
Degrees and Radians
180 degrees is equivalent to π radians.
In VCSSL, the constant PI is provided in the Math library as a predefined float-type value.

Rotation Around an Arbitrary Direction Vector

To rotate a coordinate system around an axis pointing in an arbitrary direction (as seen from the parent system), use the rotCoordinate(...) function:

- Function Format -

void rotCoordinate (
  int coordinateID,
  float angle,
  float vx, float vy, float vz
)

Arguments:

  • coordinateID: The ID of the coordinate system to rotate.
  • angle: The angle of rotation in radians (right-hand rule applies).
  • vx, vy, vz: The components of the direction vector defining the axis of rotation.

Rotation Around a Vector with an Arbitrary Origin and Direction

To rotate around an axis defined not only by direction but also by an arbitrary origin (relative to the parent system), use an extended form of the rotCoordinate(...) function:

- Function Format -

void rotCoordinate (
  int coordinateID,
  float angle,
  float vx, float vy, float vz,
  float px, float py, float pz
)

Arguments:

  • coordinateID: The ID of the coordinate system to rotate.
  • angle: The angle of rotation in radians (right-hand rule applies).
  • vx, vy, vz: The direction vector components of the rotation axis.
  • px, py, pz: The position vector components for the point where the axis passes through.

Example Program

Let's create a local coordinate system, place it on top of the world coordinate system, and rotate it by 45 degrees (π/4 radians).

To help visualize the difference between local and world systems, we'll mount a smaller axis model on the local system and a larger one on the world system.

Also, to distinguish this kind of rotation from self-rotation (which will be covered next), we'll first move the local coordinate system slightly in the X direction before applying the rotation.


import graphics3d.Graphics3DFramework;
import Graphics3D;
import Math;  // For accessing the PI constant

// 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
	int coord = newCoordinate( );

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

	// Move the local system slightly along the X axis
	moveCoordinate( coord, 1.0, 0.0, 0.0 );


	// Rotate the local system 45 degrees (π/4 radians) around the Z axis
	rotCoordinateZ( coord, PI/4.0 );


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

	// Mount a large axis model on the world system
	int axis2 = newAxisModel( 3.0, 3.0, 3.0 );
	mountModel( axis2, rendererID );
}
Sample.vcssl

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

The large model is mounted on the world coordinate system, and the small model is mounted on the local coordinate system. The local system is first moved 1.0 unit in the parent system's X direction, then rotated 45 degrees around the parent system's Z axis.

Execution Result
Execution Result
A large and a small axis model appear. The small coordinate system has been rotated around the Z axis of the large one.



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!