Skip to content
Snippets Groups Projects
Commit f34895da authored by Hailong Zhu's avatar Hailong Zhu
Browse files

- added SRSConversion

parent 64cceef5
Branches
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
......
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" /> <mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/models" vcs="Git" />
</component> </component>
</project> </project>
\ No newline at end of file
...@@ -43,6 +43,8 @@ bootRun{ ...@@ -43,6 +43,8 @@ bootRun{
} }
dependencies { dependencies {
implementation 'com.github.weeb-kun:list-utils:1.0.0'
implementation 'org.webjars.npm:list-item:1.1.1'
developmentOnly 'org.springframework.boot:spring-boot-devtools' developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'org.eclipse.emf:org.eclipse.emf.ecore:2.+' implementation 'org.eclipse.emf:org.eclipse.emf.ecore:2.+'
implementation 'org.eclipse.emf:org.eclipse.emf.common:2.+' implementation 'org.eclipse.emf:org.eclipse.emf.common:2.+'
......
Subproject commit dd1da1b391da2cd0e9a801d6bb2fb0b1985d4db9 Subproject commit 51af7a83e036eac7bf619ebe59e7fbbe105318fd
...@@ -16,38 +16,59 @@ public class SRSConversion { ...@@ -16,38 +16,59 @@ public class SRSConversion {
quat_1 is the rotation of the original coordinate system (against ROOT) quat_1 is the rotation of the original coordinate system (against ROOT)
quat_2 is the rotation of the desired coordinate system (against ROOT) quat_2 is the rotation of the desired coordinate system (against ROOT)
*/ */
public static void positionInOtherSystem(Position pos, ReferenceSystem ref){ public static void switchSRS(Placing pla, ReferenceSystem ref){
IPos_DatamodelFactory datamodelFactory = IPos_DatamodelFactory.eINSTANCE; IPos_DatamodelFactory datamodelFactory = IPos_DatamodelFactory.eINSTANCE;
Position pos = pla.getPosition();
Point3D P = (Point3D) pos.getPoint(); Point3D P = (Point3D) pos.getPoint();
Point3D R1 = (Point3D) pos.getReferenceSystem().getOrigin().getPosition().getPoint();
Point3D R2 = (Point3D) ref.getOrigin().getPosition().getPoint(); Point3D R = (Point3D) ref.getOrigin().getPosition().getPoint();
Quaternion Q1 = (Quaternion) pos.getReferenceSystem().getOrigin().getOrientation(); Quaternion Q1 = (Quaternion) pla.getOrientation();
Quaternion Q2 = (Quaternion) ref.getOrigin().getOrientation(); Quaternion Q2 = (Quaternion) ref.getOrigin().getOrientation();
String ref_id = ref.getId();
String pla_ref_id = pla.getPosition().getReferenceSystem().getId();
Vector_math p1 = new Vector_math(P.getX(), P.getY(), P.getZ()); Vector_math p1 = new Vector_math(P.getX(), P.getY(), P.getZ());
Vector_math ref_1 = new Vector_math(R1.getX(), R1.getY(), R1.getZ()); Vector_math ref_org = new Vector_math(R.getX(), R.getY(), R.getZ());
Vector_math ref_2 = new Vector_math(R2.getX(), R2.getY(), R2.getZ());
Quaternion_math quat_1 = new Quaternion_math(Q1.getX(), Q1.getY(), Q1.getZ(), Q1.getW()); Quaternion_math quat_1 = new Quaternion_math(Q1.getX(), Q1.getY(), Q1.getZ(), Q1.getW());
Quaternion_math quat_2 = new Quaternion_math(Q2.getX(), Q2.getY(), Q2.getZ(), Q2.getW()); Quaternion_math quat_2 = new Quaternion_math(Q2.getX(), Q2.getY(), Q2.getZ(), Q2.getW());
//System.out.println("Quaterion_1: " + quat_1.getX() + ", "+ quat_1.getY() + ", "+ quat_1.getZ() + ", " + quat_1.getW()); //System.out.println("Quaterion_1: " + quat_1.getX() + ", "+ quat_1.getY() + ", "+ quat_1.getZ() + ", " + quat_1.getW());
//System.out.println("Quaterion_2: " + quat_2.getX() + ", "+ quat_2.getY() + ", "+ quat_2.getZ() + ", " + quat_2.getW()); //System.out.println("Quaterion_2: " + quat_2.getX() + ", "+ quat_2.getY() + ", "+ quat_2.getZ() + ", " + quat_2.getW());
//System.out.println("inversed Quaterion_1: " + quat_1.inverse().getX() + ", "+ quat_1.inverse().getY() + ", "+ quat_1.inverse().getZ() + ", " + quat_1.inverse().getW());
p1.transform(quat_1.inverse());
//System.out.println("phase 1 transfrom: " + p1.getX() + ", "+ p1.getY() + ", "+ p1.getZ()); if (ref_id == pla_ref_id) {
p1.transform(quat_2); //System.out.println("inversed Quaterion_1: " + quat_1.inverse().getX() + ", "+ quat_1.inverse().getY() + ", "+ quat_1.inverse().getZ() + ", " + quat_1.inverse().getW());
p1.add(ref_1); quat_1.mulLeft(quat_2);
p1.substract(ref_2);
//System.out.println("phase 1 transfrom: " + p1.getX() + ", "+ p1.getY() + ", "+ p1.getZ());
p1.transform(quat_2);
p1.add(ref_org);
pos.setReferenceSystem(ref.getOrigin().getPosition().getReferenceSystem());
}
else if(ref_id == ref.getOrigin().getPosition().getReferenceSystem().getId()) {
//System.out.println("inversed Quaterion_1: " + quat_1.inverse().getX() + ", "+ quat_1.inverse().getY() + ", "+ quat_1.inverse().getZ() + ", " + quat_1.inverse().getW());
quat_1.mulLeft(quat_2.inverse());
//System.out.println("phase 1 transfrom: " + p1.getX() + ", "+ p1.getY() + ", "+ p1.getZ());
p1.transform(quat_2.inverse());
p1.substract(ref_org);
pos.setReferenceSystem(ref);
}
else {
//error message
}
Q1.setX(quat_1.getX());
Q1.setY(quat_1.getY());
Q1.setZ(quat_1.getZ());
Q1.setW(quat_1.getW());
P.setX(p1.getX()); P.setX(p1.getX());
P.setY(p1.getY()); P.setY(p1.getY());
P.setZ(p1.getZ()); P.setZ(p1.getZ());
pla.setOrientation(Q1);
pos.setPoint(P); pos.setPoint(P);
pos.setReferenceSystem(ref); pla.setPosition(pos);
} }
public static void zoneInOtherSystem(Zone zone, ReferenceSystem ref){ /*public static void switchSRSZone(Zone zone, ReferenceSystem ref){
IPos_DatamodelFactory datamodelFactory = IPos_DatamodelFactory.eINSTANCE; IPos_DatamodelFactory datamodelFactory = IPos_DatamodelFactory.eINSTANCE;
EList spaceList = zone.getSpace(); EList spaceList = zone.getSpace();
for (int i = 0; i < spaceList.size(); i++) { for (int i = 0; i < spaceList.size(); i++) {
...@@ -85,5 +106,5 @@ public class SRSConversion { ...@@ -85,5 +106,5 @@ public class SRSConversion {
new_cod[1] = cod_vec.getY(); new_cod[1] = cod_vec.getY();
new_cod[2] = cod_vec.getZ(); new_cod[2] = cod_vec.getZ();
return new_cod; return new_cod;
} }*/
} }
...@@ -13,6 +13,7 @@ public class TestSRSConverter { ...@@ -13,6 +13,7 @@ public class TestSRSConverter {
Vector_math axis = new Vector_math(1, 0,0); Vector_math axis = new Vector_math(1, 0,0);
Point3D testPoint3D = datamodelFactory.createPoint3D(); Point3D testPoint3D = datamodelFactory.createPoint3D();
Position testPosition = datamodelFactory.createPosition(); Position testPosition = datamodelFactory.createPosition();
Placing testPlacing = datamodelFactory.createPlacing();
testPoint3D.setX((float) 0); testPoint3D.setX((float) 0);
testPoint3D.setY((float) 1); testPoint3D.setY((float) 1);
...@@ -38,6 +39,7 @@ public class TestSRSConverter { ...@@ -38,6 +39,7 @@ public class TestSRSConverter {
testRef_1.setOrigin(refPlacing_1); testRef_1.setOrigin(refPlacing_1);
testPosition.setPoint(testPoint3D); testPosition.setPoint(testPoint3D);
testPosition.setReferenceSystem(testRef_1); testPosition.setReferenceSystem(testRef_1);
testPlacing.setPosition(testPosition);
ReferenceSystem testRef_2 = datamodelFactory.createReferenceSystem(); ReferenceSystem testRef_2 = datamodelFactory.createReferenceSystem();
...@@ -63,7 +65,7 @@ public class TestSRSConverter { ...@@ -63,7 +65,7 @@ public class TestSRSConverter {
System.out.println("Position: refID " + ": " + testPosition.getReferenceSystem().getId()); System.out.println("Position: refID " + ": " + testPosition.getReferenceSystem().getId());
System.out.println("Position: coord " + ": " + testPosition.getPoint()); System.out.println("Position: coord " + ": " + testPosition.getPoint());
SRSConversion.positionInOtherSystem(testPosition, testRef_2); SRSConversion.switchSRS(testPlacing, testRef_2);
System.out.println("Position: refID " + ": " + testPosition.getReferenceSystem().getId()); System.out.println("Position: refID " + ": " + testPosition.getReferenceSystem().getId());
System.out.println("Position: coord " + ": " + testPosition.getPoint()); System.out.println("Position: coord " + ": " + testPosition.getPoint());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment