Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>net.imagej</groupId>
<artifactId>imagej-ops</artifactId>
<version>0.41.2-SNAPSHOT</version>
<version>0.42.0-SNAPSHOT</version>

<name>ImageJ Ops</name>
<description>ImageJ Operations: a framework for reusable algorithms.</description>
Expand Down Expand Up @@ -266,6 +266,10 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
</dependency>
<dependency>
<groupId>org.joml</groupId>
<artifactId>joml</artifactId>
</dependency>

<!-- Test scope dependencies -->
<dependency>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/imagej/ops/OpEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import net.imagej.ops.image.ImageNamespace;
import net.imagej.ops.imagemoments.ImageMomentsNamespace;
import net.imagej.ops.labeling.LabelingNamespace;
import net.imagej.ops.linalg.LinAlgNamespace;
import net.imagej.ops.logic.LogicNamespace;
import net.imagej.ops.map.neighborhood.CenterAwareComputerOp;
import net.imagej.ops.math.MathNamespace;
Expand Down Expand Up @@ -890,6 +891,11 @@ default LBPNamespace lbp() {
return namespace(LBPNamespace.class);
}

/** Gateway into ops of the "linalg" namespace */
default LinAlgNamespace linalg() {
return namespace(LinAlgNamespace.class);
}

/** Gateway into ops of the "logic" namespace. */
default LogicNamespace logic() {
return namespace(LogicNamespace.class);
Expand Down
134 changes: 134 additions & 0 deletions src/main/java/net/imagej/ops/linalg/LinAlgNamespace.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*-
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
* Copyright (C) 2014 - 2018 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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.
* #L%
*/

package net.imagej.ops.linalg;

import net.imagej.ops.AbstractNamespace;
import net.imagej.ops.Namespace;
import net.imagej.ops.OpMethod;
import net.imagej.ops.linalg.rotate.Rotate3d;
import net.imagej.ops.linalg.rotate.Rotate3f;

import org.joml.AxisAngle4d;
import org.joml.AxisAngle4f;
import org.joml.Quaterniond;
import org.joml.Quaterniondc;
import org.joml.Quaternionf;
import org.joml.Quaternionfc;
import org.joml.Vector3d;
import org.joml.Vector3f;
import org.scijava.plugin.Plugin;

/**
* The linear algebra namespace has ops for vectors and matrices.
*
* @author Richard Domander (Royal Veterinary College, London)
*/
@Plugin(type = Namespace.class)
public class LinAlgNamespace extends AbstractNamespace {

@OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3f.class)
public Vector3f rotate(final Vector3f v, final Quaternionfc q) {
return (Vector3f) ops().run(Rotate3f.class, v, q);
}

@OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3f.class)
public Vector3f rotate(final Vector3f out, final Vector3f v,
final Quaternionfc q)
{
return (Vector3f) ops().run(Rotate3f.class, out, v, q);
}

@OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3d.class)
public Vector3d rotate(final Vector3d v, final Quaterniondc q) {
return (Vector3d) ops().run(Rotate3d.class, v, q);
}

@OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3d.class)
public Vector3d rotate(final Vector3d out, final Vector3d v,
final Quaterniondc q)
{
return (Vector3d) ops().run(Rotate3d.class, out, v, q);
}

@OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3d.class)
public Vector3d rotate(final Vector3d v, final AxisAngle4d axisAngle) {
final Quaterniondc q = new Quaterniond(axisAngle);
return (Vector3d) ops().run(Rotate3d.class, v, q);
}

@OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3f.class)
public Vector3f rotate(final Vector3f v, final AxisAngle4f axisAngle) {
final Quaternionfc q = new Quaternionf(axisAngle);
return (Vector3f) ops().run(Rotate3f.class, v, q);
}

@OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3d.class)
public Vector3d rotate(final Vector3d out, final Vector3d v,
final AxisAngle4d axisAngle)
{
final Quaterniondc q = new Quaterniond(axisAngle);
return (Vector3d) ops().run(Rotate3d.class, out, v, q);
}

@OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3f.class)
public Vector3f rotate(final Vector3f out, final Vector3f v,
final AxisAngle4f axisAngle)
{
final Quaternionfc q = new Quaternionf(axisAngle);
return (Vector3f) ops().run(Rotate3f.class, out, v, q);
}

@OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3d.class)
public Vector3d rotate1(final Vector3d v, final Quaterniondc q) {
return (Vector3d) ops().run(Rotate3d.class, v, v, q);
}

@OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3f.class)
public Vector3f rotate1(final Vector3f v, final Quaternionfc q) {
return (Vector3f) ops().run(Rotate3f.class, v, v, q);
}

@OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3d.class)
public Vector3d rotate1(final Vector3d v, final AxisAngle4d axisAngle) {
final Quaterniondc q = new Quaterniond(axisAngle);
return (Vector3d) ops().run(Rotate3d.class, v, v, q);
}

@OpMethod(op = net.imagej.ops.linalg.rotate.Rotate3f.class)
public Vector3f rotate1(final Vector3f v, final AxisAngle4f axisAngle) {
final Quaternionfc q = new Quaternionf(axisAngle);
return (Vector3f) ops().run(Rotate3f.class, v, v, q);
}

@Override
public String getName() {
return "linalg";
}
}
69 changes: 69 additions & 0 deletions src/main/java/net/imagej/ops/linalg/rotate/Rotate3d.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*-
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
* Copyright (C) 2014 - 2018 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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.
* #L%
*/

package net.imagej.ops.linalg.rotate;

import net.imagej.ops.Ops;
import net.imagej.ops.special.hybrid.AbstractBinaryHybridCFI1;

import org.joml.Quaterniondc;
import org.joml.Vector3d;
import org.scijava.plugin.Plugin;

/**
* Rotates the vector by the quaternion.
*
* @author Richard Domander (Royal Veterinary College, London)
*/
@Plugin(type = Ops.LinAlg.Rotate.class)
public class Rotate3d extends
AbstractBinaryHybridCFI1<Vector3d, Quaterniondc, Vector3d> implements
Ops.LinAlg.Rotate
{

@Override
public void compute(final Vector3d v, final Quaterniondc q,
final Vector3d vDot)
{
vDot.set(v);
vDot.rotate(q);
}

@Override
public Vector3d createOutput(final Vector3d input1,
final Quaterniondc input2)
{
return new Vector3d();
}

@Override
public void mutate1(final Vector3d v, final Quaterniondc q) {
v.rotate(q);
}
}
67 changes: 67 additions & 0 deletions src/main/java/net/imagej/ops/linalg/rotate/Rotate3f.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*-
* #%L
* ImageJ software for multidimensional image processing and analysis.
* %%
* Copyright (C) 2014 - 2018 ImageJ developers.
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 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.
* #L%
*/

package net.imagej.ops.linalg.rotate;

import net.imagej.ops.Ops;
import net.imagej.ops.special.hybrid.AbstractBinaryHybridCFI1;

import org.joml.Quaternionfc;
import org.joml.Vector3f;
import org.scijava.plugin.Plugin;

/**
* Rotates the vector by the quaternion.
*
* @author Richard Domander (Royal Veterinary College, London)
*/
@Plugin(type = Ops.LinAlg.Rotate.class)
public class Rotate3f extends
AbstractBinaryHybridCFI1<Vector3f, Quaternionfc, Vector3f> implements
Ops.LinAlg.Rotate
{

@Override
public void compute(final Vector3f v, final Quaternionfc q,
final Vector3f vDot)
{
vDot.set(v);
vDot.rotate(q);
}

@Override
public Vector3f createOutput(final Vector3f v, final Quaternionfc q) {
return new Vector3f();
}

@Override
public void mutate1(final Vector3f v, final Quaternionfc q) {
v.rotate(q);
}
}
3 changes: 3 additions & 0 deletions src/main/templates/net/imagej/ops/Ops.list
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ namespaces = ```
[name: "lbp", iface: "LBP", ops: [
[name: "lbp2D", iface: "LBP2D"]
]],
[name: "linalg", iface: "LinAlg", ops: [
[name: "rotate", iface: "Rotate"]
]],
[name: "logic", iface: "Logic", ops: [
[name: "and", iface: "And"],
[name: "bool", iface: "Bool"],
Expand Down
Loading