0

# Model up direction on sphere surface

**This discussion was imported from CodePlex**

**Cowhide** wrote at 2014-01-16 22:04:

I want to position loaded models (.obj) on the surface of a sphere (like the Earth demo for example) but I want them to stay "up", point towards the normal direction. Problem is I can't seem to find a way to set the normal of a loaded model.
From what I gather, the normal can be computed as:

Vector3D normal = (placementPosition - centerOfSphere).Normalize

So lets say I have a Point3D for the position of the object. I then translate transform the objects position to put it at this point which works. Next is to rotate it somehow to that it is pointing "up". This is the part I'm missing. Please be gentle, just learning 3D programming.

Thanks!

Vector3D normal = (placementPosition - centerOfSphere).Normalize

So lets say I have a Point3D for the position of the object. I then translate transform the objects position to put it at this point which works. Next is to rotate it somehow to that it is pointing "up". This is the part I'm missing. Please be gentle, just learning 3D programming.

Thanks!

**objo** wrote at 2014-01-23 20:07:

You need to specify one more vector that defines the orientation of the model.

Then use the Vector3D.CrossProduct to find a vector that is perpendicular to the two others. Normalize the vectors and now you have an orthonormal basis.

Define a Matrix3D where m11-m33 are the components of the three vectors (defined in rows or columns, I never remember...) and finally create a MatrixTransform3D.

This would be a nice example to add to the example browser - e.g. a sphere with the earth texture and the eiffel tower model - they are already in there!

Then use the Vector3D.CrossProduct to find a vector that is perpendicular to the two others. Normalize the vectors and now you have an orthonormal basis.

Define a Matrix3D where m11-m33 are the components of the three vectors (defined in rows or columns, I never remember...) and finally create a MatrixTransform3D.

This would be a nice example to add to the example browser - e.g. a sphere with the earth texture and the eiffel tower model - they are already in there!

Customer support service by UserEcho