Package toxi.math

Examples of toxi.math.ScaleMap


    public ToneMap(float min, float max, ColorGradient gradient) {
        this(min, max, gradient.calcGradient());
    }

    public ToneMap(float min, float max, ColorList c) {
        map = new ScaleMap(min, max, 0, c.size() - 1);
        colors = c;
    }
View Full Code Here


            ReadonlyTColor colB, int res) {
        ColorGradient g = new ColorGradient();
        g.addColorAt(0, colA);
        g.addColorAt(res - 1, colB);
        colors = g.calcGradient(0, res);
        map = new ScaleMap(min, max, 0, colors.size() - 1);
    }
View Full Code Here

        List<Float> edgeLengths = new ArrayList<Float>(mesh.edges.size());
        for (WingedEdge e : mesh.edges.values()) {
            edgeLengths.add(e.getLength());
        }
        FloatRange range = FloatRange.fromSamples(edgeLengths);
        ScaleMap brushSize = new ScaleMap(range.min, range.max, stroke.min,
                stroke.max);
        for (WingedEdge e : mesh.edges.values()) {
            brush.setSize((float) brushSize.getClippedValueFor(e.getLength()));
            createLattice(brush, e, drawStep);
        }
        volume.closeSides();
        return volume;
    }
View Full Code Here

    }

    public void setInputBounds(AABB box) {
        Vec3D bmin = box.getMin();
        Vec3D bmax = box.getMax();
        bboxToVoxelX = new ScaleMap(bmin.x, bmax.x, voxRangeX.min,
                voxRangeX.max);
        bboxToVoxelY = new ScaleMap(bmin.y, bmax.y, voxRangeY.min,
                voxRangeY.max);
        bboxToVoxelZ = new ScaleMap(bmin.z, bmax.z, voxRangeZ.min,
                voxRangeZ.max);
    }
View Full Code Here

    public VolumetricSpace voxelizeMesh(Mesh3D mesh, float iso) {
        AABB box = mesh.getBoundingBox();
        Vec3D bmin = box.getMin();
        Vec3D bmax = box.getMax();
        ScaleMap wx = new ScaleMap(bmin.x, bmax.x, 1, volume.resX - 2);
        ScaleMap wy = new ScaleMap(bmin.y, bmax.y, 1, volume.resY - 2);
        ScaleMap wz = new ScaleMap(bmin.z, bmax.z, 1, volume.resZ - 2);
        ScaleMap gx = new ScaleMap(1, volume.resX - 2, bmin.x, bmax.x);
        ScaleMap gy = new ScaleMap(1, volume.resY - 2, bmin.y, bmax.y);
        ScaleMap gz = new ScaleMap(1, volume.resZ - 2, bmin.z, bmax.z);
        volume.setScale(box.getExtent().scale(2f));
        Triangle3D tri = new Triangle3D();
        AABB voxel = new AABB(new Vec3D(), volume.voxelSize.scale(0.5f));
        for (Face f : mesh.getFaces()) {
            tri.a = f.a;
            tri.b = f.b;
            tri.c = f.c;
            AABB bounds = tri.getBoundingBox();
            Vec3D min = bounds.getMin();
            Vec3D max = bounds.getMax();
            min = new Vec3D((int) wx.getClippedValueFor(min.x),
                    (int) wy.getClippedValueFor(min.y),
                    (int) wz.getClippedValueFor(min.z));
            max = new Vec3D((int) wx.getClippedValueFor(max.x),
                    (int) wy.getClippedValueFor(max.y),
                    (int) wz.getClippedValueFor(max.z));
            for (int z = (int) min.z; z <= max.z; z++) {
                for (int y = (int) min.y; y <= max.y; y++) {
                    for (int x = (int) min.x; x <= max.x; x++) {
                        if (x < volume.resX1 && y < volume.resY1
                                && z < volume.resZ1) {
                            voxel.set((float) gx.getClippedValueFor(x),
                                    (float) gy.getClippedValueFor(y),
                                    (float) gz.getClippedValueFor(z));
                            if (voxel.intersectsTriangle(tri)) {
                                setVoxelAt(x, y, z, iso);
                            }
                        }
                    }
View Full Code Here

    }

    protected List<Vec2D> createInsidePoints(Polygon2D poly, Rect bounds) {
        List<Vec2D> points = new ArrayList<Vec2D>();
        int ires = (int) res;
        ScaleMap xmap = new ScaleMap(0, ires, bounds.getLeft(),
                bounds.getRight());
        ScaleMap ymap = new ScaleMap(0, ires, bounds.getTop(),
                bounds.getBottom());
        for (int y = 0; y < ires; y++) {
            float yy = (float) ymap.getMappedValueFor(y);
            for (int x = 0; x < ires; x++) {
                Vec2D p = new Vec2D((float) xmap.getMappedValueFor(x), yy);
                if (poly.containsPoint(p)) {
                    points.add(p);
                }
View Full Code Here

TOP

Related Classes of toxi.math.ScaleMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.