|
| 1 | +/*- |
| 2 | + * #%L |
| 3 | + * ImageJ software for multidimensional image processing and analysis. |
| 4 | + * %% |
| 5 | + * Copyright (C) 2014 - 2018 ImageJ developers. |
| 6 | + * %% |
| 7 | + * Redistribution and use in source and binary forms, with or without |
| 8 | + * modification, are permitted provided that the following conditions are met: |
| 9 | + * |
| 10 | + * 1. Redistributions of source code must retain the above copyright notice, |
| 11 | + * this list of conditions and the following disclaimer. |
| 12 | + * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 13 | + * this list of conditions and the following disclaimer in the documentation |
| 14 | + * and/or other materials provided with the distribution. |
| 15 | + * |
| 16 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE |
| 20 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 23 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 25 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 26 | + * POSSIBILITY OF SUCH DAMAGE. |
| 27 | + * #L% |
| 28 | + */ |
| 29 | + |
| 30 | +package net.imagej.ops.linalg; |
| 31 | + |
| 32 | +import net.imagej.ops.AbstractNamespace; |
| 33 | +import net.imagej.ops.Namespace; |
| 34 | +import net.imagej.ops.OpMethod; |
| 35 | +import net.imagej.ops.linalg.rotate.Rotate3d; |
| 36 | +import net.imagej.ops.linalg.rotate.Rotate3f; |
| 37 | + |
| 38 | +import org.joml.AxisAngle4d; |
| 39 | +import org.joml.AxisAngle4f; |
| 40 | +import org.joml.Quaterniond; |
| 41 | +import org.joml.Quaterniondc; |
| 42 | +import org.joml.Quaternionf; |
| 43 | +import org.joml.Quaternionfc; |
| 44 | +import org.joml.Vector3d; |
| 45 | +import org.joml.Vector3f; |
| 46 | +import org.scijava.plugin.Plugin; |
| 47 | + |
| 48 | +/** |
| 49 | + * The linear algebra namespace has ops for vectors and matrices. |
| 50 | + * |
| 51 | + * @author Richard Domander (Royal Veterinary College, London) |
| 52 | + */ |
| 53 | +@Plugin(type = Namespace.class) |
| 54 | +public class LinAlgNamespace extends AbstractNamespace { |
| 55 | + |
| 56 | + @OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3f.class) |
| 57 | + public Vector3f rotate(final Vector3f v, final Quaternionfc q) { |
| 58 | + return (Vector3f) ops().run(Rotate3f.class, v, q); |
| 59 | + } |
| 60 | + |
| 61 | + @OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3f.class) |
| 62 | + public Vector3f rotate(final Vector3f out, final Vector3f v, |
| 63 | + final Quaternionfc q) |
| 64 | + { |
| 65 | + return (Vector3f) ops().run(Rotate3f.class, out, v, q); |
| 66 | + } |
| 67 | + |
| 68 | + @OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3d.class) |
| 69 | + public Vector3d rotate(final Vector3d v, final Quaterniondc q) { |
| 70 | + return (Vector3d) ops().run(Rotate3d.class, v, q); |
| 71 | + } |
| 72 | + |
| 73 | + @OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3d.class) |
| 74 | + public Vector3d rotate(final Vector3d out, final Vector3d v, |
| 75 | + final Quaterniondc q) |
| 76 | + { |
| 77 | + return (Vector3d) ops().run(Rotate3d.class, out, v, q); |
| 78 | + } |
| 79 | + |
| 80 | + @OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3d.class) |
| 81 | + public Vector3d rotate(final Vector3d v, final AxisAngle4d axisAngle) { |
| 82 | + final Quaterniondc q = new Quaterniond(axisAngle); |
| 83 | + return (Vector3d) ops().run(Rotate3d.class, v, q); |
| 84 | + } |
| 85 | + |
| 86 | + @OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3f.class) |
| 87 | + public Vector3f rotate(final Vector3f v, final AxisAngle4f axisAngle) { |
| 88 | + final Quaternionfc q = new Quaternionf(axisAngle); |
| 89 | + return (Vector3f) ops().run(Rotate3f.class, v, q); |
| 90 | + } |
| 91 | + |
| 92 | + @OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3d.class) |
| 93 | + public Vector3d rotate(final Vector3d out, final Vector3d v, |
| 94 | + final AxisAngle4d axisAngle) |
| 95 | + { |
| 96 | + final Quaterniondc q = new Quaterniond(axisAngle); |
| 97 | + return (Vector3d) ops().run(Rotate3d.class, out, v, q); |
| 98 | + } |
| 99 | + |
| 100 | + @OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3f.class) |
| 101 | + public Vector3f rotate(final Vector3f out, final Vector3f v, |
| 102 | + final AxisAngle4f axisAngle) |
| 103 | + { |
| 104 | + final Quaternionfc q = new Quaternionf(axisAngle); |
| 105 | + return (Vector3f) ops().run(Rotate3f.class, out, v, q); |
| 106 | + } |
| 107 | + |
| 108 | + @OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3d.class) |
| 109 | + public Vector3d rotate1(final Vector3d v, final Quaterniondc q) { |
| 110 | + return (Vector3d) ops().run(Rotate3d.class, v, v, q); |
| 111 | + } |
| 112 | + |
| 113 | + @OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3f.class) |
| 114 | + public Vector3f rotate1(final Vector3f v, final Quaternionfc q) { |
| 115 | + return (Vector3f) ops().run(Rotate3f.class, v, v, q); |
| 116 | + } |
| 117 | + |
| 118 | + @OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3d.class) |
| 119 | + public Vector3d rotate1(final Vector3d v, final AxisAngle4d axisAngle) { |
| 120 | + final Quaterniondc q = new Quaterniond(axisAngle); |
| 121 | + return (Vector3d) ops().run(Rotate3d.class, v, v, q); |
| 122 | + } |
| 123 | + |
| 124 | + @OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3f.class) |
| 125 | + public Vector3f rotate1(final Vector3f v, final AxisAngle4f axisAngle) { |
| 126 | + final Quaternionfc q = new Quaternionf(axisAngle); |
| 127 | + return (Vector3f) ops().run(Rotate3f.class, v, v, q); |
| 128 | + } |
| 129 | + |
| 130 | + @Override |
| 131 | + public String getName() { |
| 132 | + return "linalg"; |
| 133 | + } |
| 134 | +} |
0 commit comments