1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.orekit.files.ccsds.ndm.adm.acm;
19
20 import java.io.IOException;
21
22 import org.hipparchus.linear.RealMatrix;
23 import org.orekit.files.ccsds.definitions.Units;
24 import org.orekit.files.ccsds.section.AbstractWriter;
25 import org.orekit.files.ccsds.utils.generation.Generator;
26 import org.orekit.utils.AccurateFormatter;
27 import org.orekit.utils.units.Unit;
28
29
30
31
32
33 class AttitudePhysicalPropertiesWriter extends AbstractWriter {
34
35
36 private final AttitudePhysicalProperties phys;
37
38
39
40
41 AttitudePhysicalPropertiesWriter(final AttitudePhysicalProperties phys) {
42 super(AcmDataSubStructureKey.phys.name(), AcmDataSubStructureKey.PHYS.name());
43 this.phys = phys;
44 }
45
46
47 @Override
48 protected void writeContent(final Generator generator) throws IOException {
49
50
51 generator.writeComments(phys.getComments());
52
53
54 generator.writeEntry(AttitudePhysicalPropertiesKey.DRAG_COEFF.name(), phys.getDragCoefficient(), Unit.ONE, false);
55
56
57 generator.writeEntry(AttitudePhysicalPropertiesKey.WET_MASS.name(), phys.getWetMass(), Unit.KILOGRAM, false);
58 generator.writeEntry(AttitudePhysicalPropertiesKey.DRY_MASS.name(), phys.getDryMass(), Unit.KILOGRAM, false);
59
60
61 if (phys.getCenterOfPressureReferenceFrame() != null) {
62 generator.writeEntry(AttitudePhysicalPropertiesKey.CP_REF_FRAME.name(), phys.getCenterOfPressureReferenceFrame().getName(), null, false);
63 }
64 if (phys.getCenterOfPressure() != null) {
65 final StringBuilder cp = new StringBuilder();
66 cp.append(AccurateFormatter.format(Unit.METRE.fromSI(phys.getCenterOfPressure().getX())));
67 cp.append(' ');
68 cp.append(AccurateFormatter.format(Unit.METRE.fromSI(phys.getCenterOfPressure().getY())));
69 cp.append(' ');
70 cp.append(AccurateFormatter.format(Unit.METRE.fromSI(phys.getCenterOfPressure().getZ())));
71 generator.writeEntry(AttitudePhysicalPropertiesKey.CP.name(), cp.toString(), Unit.METRE, false);
72 }
73
74
75 if (phys.getInertiaReferenceFrame() != null) {
76 generator.writeEntry(AttitudePhysicalPropertiesKey.INERTIA_REF_FRAME.name(), phys.getInertiaReferenceFrame().getName(), null, false);
77 }
78 final RealMatrix inertia = phys.getInertiaMatrix();
79 if (inertia != null) {
80 generator.writeEntry(AttitudePhysicalPropertiesKey.IXX.name(), inertia.getEntry(0, 0), Units.KG_M2, true);
81 generator.writeEntry(AttitudePhysicalPropertiesKey.IYY.name(), inertia.getEntry(1, 1), Units.KG_M2, true);
82 generator.writeEntry(AttitudePhysicalPropertiesKey.IZZ.name(), inertia.getEntry(2, 2), Units.KG_M2, true);
83 generator.writeEntry(AttitudePhysicalPropertiesKey.IXY.name(), inertia.getEntry(0, 1), Units.KG_M2, true);
84 generator.writeEntry(AttitudePhysicalPropertiesKey.IXZ.name(), inertia.getEntry(0, 2), Units.KG_M2, true);
85 generator.writeEntry(AttitudePhysicalPropertiesKey.IYZ.name(), inertia.getEntry(1, 2), Units.KG_M2, true);
86 }
87
88 }
89
90 }