Search in sources :

Example 1 with ThreeSpacePoint

use of cbit.vcell.geometry.concept.ThreeSpacePoint in project vcell by virtualcell.

the class SphereTestFixture method getTestSphere.

/**
 * @return test spherical tessellation
 * @throws ProgrammingException if not {@link #isSphereTest()}
 */
public List<? extends Polygon> getTestSphere() {
    if (isSphereTest()) {
        IcoSphere icoSphere = IcoSphere.get();
        List<PolygonImmutable> tessel = icoSphere.getTessellation(level);
        ThreeSpacePoint centerPoint = new ThreeSpacePointImmutable(center[0], center[1], center[2]);
        List<Triangle> tl = Triangle.scale(tessel, radius, centerPoint);
        return tl;
    }
    throw new ProgrammingException("getTestSphere called on non test Simulation");
}
Also used : ThreeSpacePointImmutable(cbit.vcell.geometry.concept.ThreeSpacePointImmutable) PolygonImmutable(cbit.vcell.geometry.concept.PolygonImmutable) Triangle(cbit.vcell.geometry.surface.Triangle) ThreeSpacePoint(cbit.vcell.geometry.concept.ThreeSpacePoint) ProgrammingException(org.vcell.util.ProgrammingException) IcoSphere(cbit.vcell.geometry.surface.IcoSphere)

Example 2 with ThreeSpacePoint

use of cbit.vcell.geometry.concept.ThreeSpacePoint in project vcell by virtualcell.

the class IcoSphere method refine.

/**
 * refine tessellation by breaking each triangle into 4
 * @param in
 * @return new list
 */
List<PolygonImmutable> refine(List<PolygonImmutable> in) {
    ArrayList<PolygonImmutable> rval = new ArrayList<>(in.size() * 4);
    for (PolygonImmutable t : in) {
        ThreeSpacePoint v1 = t.getNodes(0);
        ThreeSpacePoint v2 = t.getNodes(1);
        ThreeSpacePoint v3 = t.getNodes(2);
        ThreeSpacePoint a = middleOf(v1, v2);
        ThreeSpacePoint b = middleOf(v2, v3);
        ThreeSpacePoint c = middleOf(v3, v1);
        rval.add(new PolygonImmutable(v1, a, c));
        lastTriEdge(rval);
        rval.add(new PolygonImmutable(v2, b, a));
        lastTriEdge(rval);
        rval.add(new PolygonImmutable(v3, c, b));
        lastTriEdge(rval);
        rval.add(new PolygonImmutable(a, b, c));
        lastTriEdge(rval);
    }
    return rval;
}
Also used : PolygonImmutable(cbit.vcell.geometry.concept.PolygonImmutable) ArrayList(java.util.ArrayList) ThreeSpacePoint(cbit.vcell.geometry.concept.ThreeSpacePoint)

Example 3 with ThreeSpacePoint

use of cbit.vcell.geometry.concept.ThreeSpacePoint in project vcell by virtualcell.

the class IcoSphere method middleOf.

private ThreeSpacePoint middleOf(ThreeSpacePoint v1, ThreeSpacePoint v2) {
    NodePair np = new NodePair(v1, v2);
    ThreeSpacePoint n = middleMap.get(np);
    if (n != null) {
        return n;
    }
    double x = average(v1, v2, ThreeSpacePoint::getX);
    double y = average(v1, v2, ThreeSpacePoint::getY);
    double z = average(v1, v2, ThreeSpacePoint::getZ);
    ThreeSpacePoint mid = unitNode(x, y, z);
    middleMap.put(np, mid);
    return mid;
}
Also used : ThreeSpacePoint(cbit.vcell.geometry.concept.ThreeSpacePoint)

Example 4 with ThreeSpacePoint

use of cbit.vcell.geometry.concept.ThreeSpacePoint in project vcell by virtualcell.

the class IcoSphere method icosahedron.

private List<PolygonImmutable> icosahedron() {
    double[][] vertexTable = { // 0
    { -1, T_CONSTANT, 0 }, // 1
    { 1, T_CONSTANT, 0 }, // 2
    { -1, -T_CONSTANT, 0 }, // 3
    { 1, -T_CONSTANT, 0 }, // 4
    { 0, -1, T_CONSTANT }, // 5
    { 0, 1, T_CONSTANT }, // 6
    { 0, -1, -T_CONSTANT }, // 7
    { 0, 1, -T_CONSTANT }, { T_CONSTANT, 0, -1 }, { T_CONSTANT, 0, 1 }, { -T_CONSTANT, 0, -1 }, { -T_CONSTANT, 0, 1 } };
    List<ThreeSpacePoint> nodes = new ArrayList<>();
    for (int n = 0; n < vertexTable.length; n++) {
        nodes.add(n, unitNode(vertexTable[n][0], vertexTable[n][1], vertexTable[n][2]));
    }
    int[][] triTable = { { 0, 11, 5 }, { 0, 5, 1 }, { 0, 1, 7 }, { 0, 7, 10 }, { 0, 10, 11 }, { 1, 5, 9 }, { 5, 11, 4 }, { 11, 10, 2 }, { 10, 7, 6 }, { 7, 1, 8 }, { 3, 9, 4 }, { 3, 4, 2 }, { 3, 2, 6 }, { 3, 6, 8 }, { 3, 8, 9 }, { 4, 9, 5 }, { 2, 4, 11 }, { 6, 2, 10 }, { 8, 6, 7 }, { 9, 8, 1 } };
    ArrayList<PolygonImmutable> rval = new ArrayList<>(triTable.length);
    for (int t = 0; t < triTable.length; t++) {
        ThreeSpacePoint a = nodes.get(triTable[t][0]);
        ThreeSpacePoint b = nodes.get(triTable[t][1]);
        ThreeSpacePoint c = nodes.get(triTable[t][2]);
        PolygonImmutable tri = new PolygonImmutable(a, b, c);
        rval.add(tri);
    }
    return rval;
}
Also used : PolygonImmutable(cbit.vcell.geometry.concept.PolygonImmutable) ArrayList(java.util.ArrayList) ThreeSpacePoint(cbit.vcell.geometry.concept.ThreeSpacePoint) ThreeSpacePoint(cbit.vcell.geometry.concept.ThreeSpacePoint)

Aggregations

ThreeSpacePoint (cbit.vcell.geometry.concept.ThreeSpacePoint)4 PolygonImmutable (cbit.vcell.geometry.concept.PolygonImmutable)3 ArrayList (java.util.ArrayList)2 ThreeSpacePointImmutable (cbit.vcell.geometry.concept.ThreeSpacePointImmutable)1 IcoSphere (cbit.vcell.geometry.surface.IcoSphere)1 Triangle (cbit.vcell.geometry.surface.Triangle)1 ProgrammingException (org.vcell.util.ProgrammingException)1