Skip to content

Commit

Permalink
Import Thoth, adapt (heavily) to Sentinel. First skeleton + muscle
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Aug 27, 2023
1 parent 6c77645 commit e013247
Show file tree
Hide file tree
Showing 17 changed files with 1,216 additions and 6 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<module>e2e-test</module>
<module>sentinel</module>
<module>portal</module>
<module>thoth</module>
</modules>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.hellblazer.luciferase.sentinel;

import java.util.LinkedList;
import java.util.List;
import java.util.Set;

/**
Expand Down Expand Up @@ -56,10 +57,10 @@ public int hashCode() {
}
}

private LinkedList<OrientedFace> ears = new LinkedList<>();
private Set<Ear> visited = new OaHashSet<>();
private List<OrientedFace> ears = new LinkedList<>();
private Set<Ear> visited = new OaHashSet<>();

public LinkedList<OrientedFace> getEars() {
public List<OrientedFace> getEars() {
return ears;
}

Expand Down
105 changes: 105 additions & 0 deletions sentinel/src/main/java/com/hellblazer/luciferase/sentinel/SOI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/**
* Copyright (C) 2023 Hal Hildebrand. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.hellblazer.luciferase.sentinel;

import java.util.Collection;

import javax.vecmath.Tuple3f;

import com.hellblazer.luciferase.thoth.Perceiving;
import com.hellblazer.luciferase.thoth.impl.Node;
import com.hellblazer.luciferase.thoth.impl.SphereOfInteraction;

/**
* Sentinel implementation of the Thoth sphere o' interaction
*
* @author hal.hildebrand
*/
public class SOI implements SphereOfInteraction {

@Override
public <T extends Perceiving> Node<T> closestTo(Tuple3f point3f) {
// TODO Auto-generated method stub
return null;
}

@Override
public <T extends Perceiving> Node<T> getAliased(Node<?> node) {
// TODO Auto-generated method stub
return null;
}

@Override
public Collection<Node<?>> getEnclosingNeighbors(Node<?> id) {
// TODO Auto-generated method stub
return null;
}

@Override
public Iterable<Node<?>> getNodes() {
// TODO Auto-generated method stub
return null;
}

@Override
public Collection<Node<?>> getPeers() {
// TODO Auto-generated method stub
return null;
}

@Override
public boolean includes(Node<?> node) {
// TODO Auto-generated method stub
return false;
}

@Override
public <T extends Perceiving> void insert(Node<T> id, Tuple3f point3f) {
// TODO Auto-generated method stub

}

@Override
public <T extends Perceiving> boolean isBoundary(Node<T> node, Tuple3f center, float radiusSquared) {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean isEnclosing(Node<?> node, Node<?> center_node_id) {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean overlaps(Node<?> node, Tuple3f center, float radiusSquared) {
// TODO Auto-generated method stub
return false;
}

@Override
public void remove(Node<?> node) {
// TODO Auto-generated method stub

}

@Override
public void update(Node<?> node, Tuple3f coord) {
// TODO Auto-generated method stub

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,19 @@
*/
@FunctionalInterface
public interface StarVisitor {
void visit(V vertex, Tetrahedron t, Vertex x, Vertex y, Vertex z);
/**
* Visit the tetrahedron t in the start set. The central vertex of the star set
* is vertex v in tetrahedron t. The other 3 vertices in tetrahedron t are given
* by {a, b, c} and are in counter clockwise order, where the central vertex of
* the star is V ordinal D in t, following the right hand rule.
*
* @param v - the V Ordinal of the central vertex Vc of the star in tetrahedron
* t
* @param t - a tetrahedron in the star set, where the central vertex of the
* start is the vertex ordinal in t
* @param a - vertext A relative to Vc
* @param b - vertext B relative to Vc
* @param c - vertext C relative to Vc
*/
void visit(V v, Tetrahedron t, Vertex a, Vertex b, Vertex c);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Collection;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Random;
Expand Down Expand Up @@ -154,7 +153,7 @@ public final Tetrahedron getAdjacent() {
return adjacent;
}

public final LinkedList<OrientedFace> getEars() {
public final List<OrientedFace> getEars() {
assert adjacent != null;
EarSet aggregator = new EarSet();
adjacent.visitStar(this, aggregator);
Expand Down Expand Up @@ -258,6 +257,13 @@ public Vertex next() {
};
}

/**
* Locate the tetrahedron encompassing the query point
*
* @param query
* @param entropy - entropy used for randomization of search
* @return the Tetrahedron that encompasses the query point
*/
public final Tetrahedron locate(Tuple3f query, Random entropy) {
assert adjacent != null;
return adjacent.locate(query, entropy);
Expand Down Expand Up @@ -294,6 +300,11 @@ public String toString() {
return "{" + x + ", " + y + ", " + z + "}";
}

public final void visitNeighbors(StarVisitor visitor) {
assert adjacent != null;
adjacent.visitStar(this, visitor);
}

void append(Vertex v) {
assert next == null : "Next is not null";
next = v;
Expand Down
31 changes: 31 additions & 0 deletions sentinel/src/main/java/com/hellblazer/luciferase/thoth/Cursor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (C) 2008 Hal Hildebrand. All rights reserved.
*
* This file is part of the Thoth Interest Management and Load Balancing
* Framework.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.hellblazer.luciferase.thoth;

/**
*
* @author <a href="mailto:hal.hildebrand@gmail.com">Hal Hildebrand</a>
*
*/

public interface Cursor extends Movable, Locatable {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (C) 2008 Hal Hildebrand. All rights reserved.
*
* This file is part of the Thoth Interest Management and Load Balancing
* Framework.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.hellblazer.luciferase.thoth;

import javax.vecmath.Tuple3f;

/**
*
* @author <a href="mailto:hal.hildebrand@gmail.com">Hal Hildebrand</a>
*
*/

public interface Locatable {

Tuple3f getLocation();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright (C) 2008 Hal Hildebrand. All rights reserved.
*
* This file is part of the Thoth Interest Management and Load Balancing
* Framework.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.hellblazer.luciferase.thoth;

import javax.vecmath.Tuple3f;

/**
*
* @author <a href="mailto:hal.hildebrand@gmail.com">Hal Hildebrand</a>
*
*/

public interface Movable {

void moveBy(Tuple3f velocity);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright (C) 2008 Hal Hildebrand. All rights reserved.
*
* This file is part of the Thoth Interest Management and Load Balancing
* Framework.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.hellblazer.luciferase.thoth;

import javax.vecmath.Point3f;
import javax.vecmath.Vector3f;

import com.hellblazer.primeMover.annotations.NonEvent;

/**
*
* @author <a href="mailto:hal.hildebrand@gmail.com">Hal Hildebrand</a>
*
*/

public interface Perceiving {

void fade(Perceiving neighbor);

void move(Perceiving neighbor, Point3f location, Vector3f velocity);

void notice(Perceiving neighbor, Point3f location);

@NonEvent
void setCursor(Cursor cursor);
}
Loading

0 comments on commit e013247

Please sign in to comment.