diff --git a/LICENSE_MathUtils_orthogonalizeRotationMatrix.txt b/LICENSE_MathUtils_orthogonalizeRotationMatrix.txt new file mode 100644 index 000000000..3b4929683 --- /dev/null +++ b/LICENSE_MathUtils_orthogonalizeRotationMatrix.txt @@ -0,0 +1,23 @@ +Copyright (c) 2022 Photon Vision. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of FIRST, WPILib, nor the names of other WPILib + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY FIRST AND OTHER WPILIB CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/photon-core/src/main/java/org/photonvision/common/util/math/MathUtils.java b/photon-core/src/main/java/org/photonvision/common/util/math/MathUtils.java index 8e8d1ef40..cd035555f 100644 --- a/photon-core/src/main/java/org/photonvision/common/util/math/MathUtils.java +++ b/photon-core/src/main/java/org/photonvision/common/util/math/MathUtils.java @@ -104,7 +104,7 @@ public class MathUtils { return list.get(0); // always return single value for n = 1 } - // Sort array. We avoid a third copy here by just creating the + // Sort array. We avoid a third copy here by just creating the // list directly. double[] sorted = new double[list.size()]; for (int i = 0; i < list.size(); i++) { @@ -184,11 +184,16 @@ public class MathUtils { } /* - * The AprilTag pose rotation outputs are X left, Y down, Z away from the tag with the tag facing - * the camera upright and the camera facing the target parallel to the floor. But our OpenCV - * solvePNP code would have X left, Y up, Z towards the camera with the target facing the camera - * and both parallel to the floor. So we apply a base rotation to the rotation component of the - * apriltag pose to make it consistent with the EDN system that OpenCV uses, internally a 180 + * The AprilTag pose rotation outputs are X left, Y down, Z away from the tag + * with the tag facing + * the camera upright and the camera facing the target parallel to the floor. + * But our OpenCV + * solvePNP code would have X left, Y up, Z towards the camera with the target + * facing the camera + * and both parallel to the floor. So we apply a base rotation to the rotation + * component of the + * apriltag pose to make it consistent with the EDN system that OpenCV uses, + * internally a 180 * rotation about the X axis */ private static final Rotation3d APRILTAG_BASE_ROTATION = @@ -213,6 +218,9 @@ public class MathUtils { * Orthogonalize an input matrix using a QR decomposition. QR decompositions decompose a * rectangular matrix 'A' such that 'A=QR', where Q is the closest orthogonal matrix to the input, * and R is an upper triangular matrix. + * + *

The following function is released under the BSD license avaliable in + * LICENSE_MathUtils_orthogonalizeRotationMatrix.txt. */ public static Matrix orthogonalizeRotationMatrix(Matrix input) { var a = DecompositionFactory_DDRM.qr(3, 3);