# AB4D Forum

Full Version: XYZ coordinates orientation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Dear Andrej and Ab3d users,

I'm still new in understanding and using these great 3D functionalities for my C# developing ...

That's why I have some fundamental questions of the concept and therefor the best way for an adequate using in my applications.

Basically, my use cases are in geographic resp. geodetic relations.

This kind of abstraction for real-life conditions has typically the following definition of XYZ coordinates orientation:
• X means from West to East direction
• Y means from South to North direction
• Z means the Height into heaven :-)
Unfortunately it seems that Ab3d is founded on a different fundamental definition, especially in such models like the HeightMap.

It's no problem with other models because I can change their XYZ coordinates orientation quite easy.

But how to solve this for HeightMap?

Thanks a lot in advance & best regards,
Hagen
WPF is using standard right handed coordinate system where X is to the right, Y up and Z "away from the screen".

Also the Ab3d.PowerToys camera work well when Y axis is pointing up. The cameras (expect FreeCamera) do not work well in any other coordinate system.

Therefore I would advise you to preserve the Y up axis and convert the coordinates of objects before you apply them to WPF 3D objects. For example if one object is at (100, 200, 300) in your coordinates, you need to show it at (100, 300, -200) coordinates in WPF.

Another solution is to define a ModelVisual3D with a MatrixTransform3D that transform coordinate system from your coordinate system to WPF coordinate system. It can be defined with the following XAML:

Code:
```<ModelVisual3D x:Name="ZUpRootVisual">     <ModelVisual3D.Transform>         <!-- The transformation defines the new axis - defined in matrix columns in upper left 3x3 part of the matrix:                 x axis - 1st column (use x value): 1 0 0                 y axis - 2nd column (use z value): 0 0 1                 z axis - 3rd column (use negative y value): 0 -1 0 -->         <MatrixTransform3D Matrix="1  0  0  0                                     0  0 -1  0                                     0  1  0  0                                     0  0  0  1" />     </ModelVisual3D.Transform>     <!-- All 3D models inside this Visual3D will have changed coordinate system with Z up and Y into the screen --> </ModelVisual3D>```

Then you can add 3D objects into this ModelVisual3D and use coordinates in your coordinate system.

But you cannot use this ModelVisual3D for HeightMapVisual3D because HeightMapVisual3D already uses Y axis as up axis. But this should not be a problem because HeightMapVisual3D already have the planar X and Y coordinates in the HeightData array and Height value that is pointing up.

If you are using CameraAxisPanel to show coordinate axes, you can change the axes direction there - see CameraPanelsSample.xaml.

For the next version of Ab3d.PowerToys (v7.4) I have prepared a simple on how to do that (without HeightMap).

You can try it with downloading the following two files:
[attachment=29]
[attachment=30]

Add them to the samples solution to the Cameras folder. Then open the Samples.xml on the root folder and add the following under Cameras:

<Sample Page="Cameras/CustomUpAxisSample.xaml" Title="Custom Up axis" Description="" />
(01-08-2016, 04:08 PM)abenedik Wrote: [ -> ]... because HeightMapVisual3D already uses Y axis as up axis. But this should not be a problem because HeightMapVisual3D already have the planar X and Y coordinates in the HeightData array and Height value that is pointing up.

Dear Andrej,

Thanks a lot for your help!

At the end of the day, it seems to be only a small problem now ... :-)

Because it's already easy to change the position and direction of my TargetPositionCamera, I can simply start the Viewport3D in the right way (related to geodetic or geographic orientation):

https://www.optimalsystem.de/os/pics/Opt...3D-Log.png

And due to its definition, HeightMapVisual3D is just adequate to this real-world XYZ orientation ... :-)

And of course I'll also try to realize your new recommendations!

Best wishes,
Hagen