November 25, 2006

Making an User Cordinate System : UCS

Filed under: 3D Maths — khangharoth @ 1:07 am

More often than not , in any CAD application user is given a choice to create its own coordinate System and he works relative to his own created UCS but System translate all UCS Points into WCS for internal calculation like drawing an entity.

Lets take an example to get this thing clear .

User is working on a big file say where : All dimension can be anything say in meters
X extends between -400 to 400
Y extends between -400 to 400
Z extends between 0 to 400

Now he wants to draw a Circle of Radius 50 whose center is at (100,100,100 )
and circle is drawn in XY plane .

And inside the circle he wants to place some more Objects so for sake of convince
he would like to have a UCS at circle center so that he can specify points with respect
to circle center .But System will draw these points in WCS in which whole drawing is specified .

To define a New Coordinate System we need UCS Origin Point and two Orthogonal Axis say
X Axis and Y Axis and Z will get defined by taking crossproduct X cross Y

UCS X and Y axis can be any direction depending on User requirement as in which plane he wants to work on . In our simplistic case User X and Y axis coincide with System X and Y axis.

So parameters that user need to create a UCS at Center are
1) UCS Origin : (100,100,0)
2) X Axis Vector : (1,0,0)
3) Y Axis Vector : (0,1,0)

And thats it now we have sufficient Input to create an UCS

So Here is Small UCS Class which have utility methods like converting WCS Point to UCS and vice versa

import javax.vecmath.Matrix4f;
import javax.vecmath.Point3f;
import javax.vecmath.Vector3f;

* @author ksingh2
public class UcsCoordinates {
private boolean isUcsSet;
private Point3f ucsCentre=new Point3f();
private Point3f ucsPoint=new Point3f();
private Vector3f ucsXAxis=new Vector3f();
private Vector3f ucsYAxis=new Vector3f();
private Vector3f ucsZAxis=new Vector3f();
private Matrix4f wcsToUcs=new Matrix4f();
private Matrix4f ucsToWcs=new Matrix4f();

* Give Point in UCS corresoponding to
* WCS Point
* @param node
* @param canvas

public Point3f getUcsCordinates(Point3f wcsPoint ) {
return ucsPoint;


*Give Point in WCS corresoponding to
* UCS Point
* @param node
* @param canvas

public Point3f getWcsCordinates(Point3f ucsPoint ) {
return ucsPoint;


* @param originPoint
* @param yAxis
* @param xAxis
public UcsCoordinates(Point3f originPoint,Vector3f yAxis ,Vector3f xAxis) {

public boolean isUcsSet() {
return isUcsSet;
public void setUcsSet(boolean isUcsSet) {
this.isUcsSet = isUcsSet;
private void reset(){
public Matrix4f getUcsToWcs() {
return ucsToWcs;

public Matrix4f getWcsToUcs() {
return wcsToUcs;

Its a basic UCS class and we can incorporate more functionality like rotation and Translation
of UCS.



Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Create a free website or blog at

%d bloggers like this: