Coordinate System

Contents

The Native Space

GermaniumWeb has its own coordinate system called the native space. The native space has the following characteristics:

Here is how the XYZ axes are arranged on GermaniumWeb on initialization. The arrows point in the positive direction.

The XYZ axes in GermaniumWeb

Representing Position

You can represent a position using a Coordinates object.

var pos = germ.CreateCoordinates(100, 1.5, 20);

Representing Orientation

You can represent an orientation using an EulerAngle object.

var ort = germ.CreateEulerAngle(0.524, 0.785, 1.571);

The rotation unit is radians. You can convert units between degrees and radians using DegreeToRadian() and RadianToDegree().

// Practically equivalent to the previous example
var ort = germ.CreateEulerAngle(Germanium.DegreeToRadian(30),
				Germanium.DegreeToRadian(45),
				Germanium.DegreeToRadian(90));

The direction of positive rotation is shown in the figure below.

The direction of positive rotation in GermaniumWeb
Tip: You can easily recall direction of positive rotation using the right hand grip rule.

Converting between 2D and 3D coordinates

Given a pixel P(a, b) on the plugin rectangle, you can compute the corresponding 3D coordinates of the scene surface Q(x, y, z) using the function Eye.Compute3DIntersection().

var eye = germ.GetEye();	// get the Eye
var a = 300, b = 200;		// input pixel coordinates P
var Q = eye.Compute3DIntersection(a, b);
alert("Computed 3D intersection = " + Q.ToString());

A related function is ConvertWindowTo3D(). It is similar to Compute3DIntersection(); but instead of asking the API to compute the position of the nearest 3D object, you specify d, the distance of the point from the Eye.

var eye = germ.GetEye();
var a = 300, b = 200, d = 100;
var P = germ.CreateCoordinates(a, b, d);	// input window coordinates
var Q;						// output 3D coordinates
var bInScene = eye.ConvertWindowTo3D(P, Q);
if (bInScene) {
	alert("Output 3D coordinates: " + Q.ToString());
} else {
	alert("Input coordinates is outside the 3D scene.");
}

Finally, Convert3DToWindow() is the inverse of ConvertWindowTo3D(). Given a 3D coordinates P(x, y, z), the function returns the corresponding pixel (a, b) on the plugin rectangle and the distance d between the input coordinates with the Eye.

var eye = germ.GetEye();
var x = 10, y = 0, z = 20;
var P = germ.CreateCoordinates(x, y, z);	// input 3D coordinates
var Q;						// output point
var a, b, d;					// output window coordinates
var bInWindow = eye.Convert3DToWindow(P, Q);
a = Q.x;
b = Q.y;
d = Q.z;
if (bInWindow) {
	alert("Output pixel coordinates: (" + a + ", " + b + "); " +
		"distance from Eye = " + d + " meters.");
} else {
	alert("Input point is outside the plugin rectangle.");
}

References

Retrieved from "http://www.germanium3d.com/code/CoordinateSystemConcepts"

This page has been accessed 53,584 times. This page was last modified on 30 April 2010, at 02:43.


Developers


Main

API Key Registration

Developer Guide
- Introduction
- Buildings
- Point Placemarks
- Line & Polygon      PlacemarksUpdated
- Model Placemarks New
- HTMLBoxes New
- Eye Control
- Clip Planes
- Events
- Coordinate System
- Navigation Modes
- Options

API Documentation

Examples
- Applications Gallery
- Hello Germanium
- Interactive samples

More Resources
- API Release Notes
- Developer FAQ
- "A Beginner's Guide" slides
- Training Materials
- Icon Gallery
- Sample Buildings
- BBL Tree

Report Bugs