From 1af17c45f3974013f75528697caa99a872277268 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe <luc@orekit.org> Date: Sat, 20 Dec 2014 17:59:40 +0100 Subject: [PATCH] Added sequences of transforms for lines-of-sight. --- .../org/orekit/rugged/los/FixedRotation.java | 45 ++++++++++++++ .../org/orekit/rugged/los/LOSBuilder.java | 62 +++++++++++++++++-- .../org/orekit/rugged/los/LOSTransform.java | 34 ++++++++++ .../orekit/rugged/los/PolynomialRotation.java | 59 ++++++++++++++++++ .../orekit/rugged/los/TimeDependentLOS.java | 2 +- src/site/xdoc/changes.xml | 3 + 6 files changed, 200 insertions(+), 5 deletions(-) create mode 100644 src/main/java/org/orekit/rugged/los/FixedRotation.java create mode 100644 src/main/java/org/orekit/rugged/los/LOSTransform.java create mode 100644 src/main/java/org/orekit/rugged/los/PolynomialRotation.java diff --git a/src/main/java/org/orekit/rugged/los/FixedRotation.java b/src/main/java/org/orekit/rugged/los/FixedRotation.java new file mode 100644 index 00000000..56368109 --- /dev/null +++ b/src/main/java/org/orekit/rugged/los/FixedRotation.java @@ -0,0 +1,45 @@ +/* Copyright 2013-2014 CS Systèmes d'Information + * Licensed to CS Systèmes d'Information (CS) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * CS licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.orekit.rugged.los; + +import org.apache.commons.math3.geometry.euclidean.threed.Rotation; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import org.orekit.time.AbsoluteDate; + +/** {@link LOSTransform LOS transform} based on a fixed rotation. + * @author Luc Maisonobe + * @see LOSBuilder + */ +public class FixedRotation implements LOSTransform { + + /** Underlying rotation. */ + final Rotation rotation; + + /** Simple constructor. + * @param rotation rotation to apply + */ + public FixedRotation(final Rotation rotation) { + this.rotation = rotation; + } + + /** {@inheritDoc} */ + @Override + public Vector3D transformLOS(int i, Vector3D los, AbsoluteDate date) { + return rotation.applyTo(los); + } + +} \ No newline at end of file diff --git a/src/main/java/org/orekit/rugged/los/LOSBuilder.java b/src/main/java/org/orekit/rugged/los/LOSBuilder.java index b54ee572..67ed4f38 100644 --- a/src/main/java/org/orekit/rugged/los/LOSBuilder.java +++ b/src/main/java/org/orekit/rugged/los/LOSBuilder.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.List; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import org.orekit.time.AbsoluteDate; /** Builder for lines-of-sight list. * <p> @@ -37,22 +38,75 @@ public class LOSBuilder { /** Raw fixed ine-of-sights. */ public final List<Vector3D> rawLOS; + /** Transforms to be applied. */ + private final List<LOSTransform> transforms; + /** Create builder. * @param rawLOS raw fixed lines-of-sight */ public LOSBuilder(final List<Vector3D> rawLOS) { this.rawLOS = rawLOS; + this.transforms = new ArrayList<LOSTransform>(); + } + + /** Add a transform to be applied after the already registered transforms. + * @param transform transform to be applied to the lines-of-sight + */ + public void addTransform(final LOSTransform transform) { + transforms.add(transform); + } /** Build a list of transformed lines-of-sight. * @return list of transformed lines of sight */ public List<TimeDependentLOS> build() { - final List<TimeDependentLOS> los = new ArrayList<TimeDependentLOS>(rawLOS.size()); - for (final Vector3D raw : rawLOS) { - los.add(new FixedLOS(raw)); + + // copy the current transforms set, to ensure immutability + // of the built list, in case addTransform is called again after build + final List<LOSTransform> copy = new ArrayList<LOSTransform>(transforms); + final List<TimeDependentLOS> transformed = new ArrayList<TimeDependentLOS>(rawLOS.size()); + for (int i = 0; i < rawLOS.size(); ++i) { + transformed.add(new TransformsSequenceLOS(i, rawLOS.get(i), copy)); + } + + return transformed; + + } + + /** Implement time-dependent LOS by applying all registered transforms. */ + private static class TransformsSequenceLOS implements TimeDependentLOS { + + /** LOS index. */ + private final int index; + + /** Raw direction. */ + private final Vector3D raw; + + /** Transforms to be applied. */ + private final List<LOSTransform> transforms; + + /** Simple constructor. + * @param index los index + * @param raw raw direction + * @param transforms transforms to apply + */ + public TransformsSequenceLOS(final int index, final Vector3D raw, final List<LOSTransform> transforms) { + this.index = index; + this.raw = raw; + this.transforms = transforms; + } + + /** {@inheritDoc} */ + @Override + public Vector3D getLOS(final AbsoluteDate date) { + Vector3D los = raw; + for (final LOSTransform transform : transforms) { + los = transform.transformLOS(index, los, date); + } + return los.normalize(); } - return los; + } } diff --git a/src/main/java/org/orekit/rugged/los/LOSTransform.java b/src/main/java/org/orekit/rugged/los/LOSTransform.java new file mode 100644 index 00000000..a628e82a --- /dev/null +++ b/src/main/java/org/orekit/rugged/los/LOSTransform.java @@ -0,0 +1,34 @@ +/* Copyright 2013-2014 CS Systèmes d'Information + * Licensed to CS Systèmes d'Information (CS) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * CS licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.orekit.rugged.los; + +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import org.orekit.time.AbsoluteDate; + +/** Interface for lines-of-sight tranforms. + * @author Luc Maisonobe + * @see LOSBuilder + */ +interface LOSTransform { + /** Transform a line-of-sight. + * @param i los pixel index + * @param los line-of-sight to transform + * @param date current date + * @return transformed line-of-sight + */ + Vector3D transformLOS(int i, Vector3D los, AbsoluteDate date); +} \ No newline at end of file diff --git a/src/main/java/org/orekit/rugged/los/PolynomialRotation.java b/src/main/java/org/orekit/rugged/los/PolynomialRotation.java new file mode 100644 index 00000000..4447af9b --- /dev/null +++ b/src/main/java/org/orekit/rugged/los/PolynomialRotation.java @@ -0,0 +1,59 @@ +/* Copyright 2013-2014 CS Systèmes d'Information + * Licensed to CS Systèmes d'Information (CS) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * CS licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.orekit.rugged.los; + +import org.apache.commons.math3.analysis.polynomials.PolynomialFunction; +import org.apache.commons.math3.geometry.euclidean.threed.Rotation; +import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import org.orekit.time.AbsoluteDate; + +/** {@link LOSTransform LOS transform} based on a rotation with polynomial angle. + * @author Luc Maisonobe + * @see LOSBuilder + */ +public class PolynomialRotation implements LOSTransform { + + /** Rotation axis. */ + final Vector3D axis; + + /** Rotation angle polynomial. */ + final PolynomialFunction angle; + + /** Reference date for polynomial evaluation. */ + final AbsoluteDate referenceDate; + + /** Simple constructor. + * @param axis rotation axis + * @param angle rotation angle as a polynomial in t, where t + * is the duration in seconds between evaluation date and reference date + * @param referenceDate reference date for the polynomial angle + */ + public PolynomialRotation(final Vector3D axis, + final PolynomialFunction angle, + final AbsoluteDate referenceDate) { + this.axis = axis; + this.angle = angle; + this.referenceDate = referenceDate; + } + + /** {@inheritDoc} */ + @Override + public Vector3D transformLOS(int i, Vector3D los, AbsoluteDate date) { + return new Rotation(axis, angle.value(date.durationFrom(referenceDate))).applyTo(los); + } + +} \ No newline at end of file diff --git a/src/main/java/org/orekit/rugged/los/TimeDependentLOS.java b/src/main/java/org/orekit/rugged/los/TimeDependentLOS.java index 6a7c7059..6e44fefc 100644 --- a/src/main/java/org/orekit/rugged/los/TimeDependentLOS.java +++ b/src/main/java/org/orekit/rugged/los/TimeDependentLOS.java @@ -27,7 +27,7 @@ import org.orekit.time.AbsoluteDate; public interface TimeDependentLOS { /** Get the line of sight for a given date. - * @param date date + * @param date date * @return line of sight */ Vector3D getLOS(AbsoluteDate date); diff --git a/src/site/xdoc/changes.xml b/src/site/xdoc/changes.xml index 0f213112..6c35af4d 100644 --- a/src/site/xdoc/changes.xml +++ b/src/site/xdoc/changes.xml @@ -22,6 +22,9 @@ <body> <release version="1.0" date="TBD" description="TBD"> + <action dev="luc" type="add" > + Added sequences of transforms for lines-of-sight. + </action> <action dev="luc" type="add" > Added a builder for line-of-sight lists. </action> -- GitLab