+/*******************************************************************************\r
+ * Copyright (c) 2012, 2013 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
package org.simantics.g3d.tools;\r
\r
import javax.vecmath.Matrix4d;\r
\r
\r
public static Vector3d getLocalPosition(IG3DNode node, Vector3d worldCoord) {\r
- \r
+ \r
IG3DNode parent = (IG3DNode)node.getParent();\r
- if (parent == null) {// this is a root node ( has no transformation) \r
- return worldCoord;\r
- }\r
+ if (parent == null) {// this is a root node ( has no transformation) \r
+ return worldCoord;\r
+ }\r
\r
- Vector3d local = getLocalPosition(parent,worldCoord);\r
- local.sub(node.getPosition());\r
- \r
- Quat4d q = new Quat4d();\r
- q.set(node.getOrientation());\r
- q.inverse();\r
- MathTools.rotate(q, local, local);\r
- \r
- return local;\r
- }\r
+ Vector3d local = getLocalPosition(parent,worldCoord);\r
+ local.sub(node.getPosition());\r
+ \r
+ Quat4d q = new Quat4d();\r
+ q.set(node.getOrientation());\r
+ q.inverse();\r
+ MathTools.rotate(q, local, local);\r
+ \r
+ return local;\r
+ }\r
\r
public static Quat4d getLocalOrientation(IG3DNode node, Quat4d worldRot) {\r
\r