Package toxi.geom

Examples of toxi.geom.Vec4D


        tmp.set(o.yAxis).scaleSelf(cosStart);
        Vec3D t0 = new Vec3D(o.xAxis).scaleSelf(-sinStart).addSelf(tmp);

        Vec4D[] cps = new Vec4D[n + 1];
        cps[0] = new Vec4D(p0, 1);
        int index = 0;
        double angle = thetaStart;

        Vec3D p1 = new Vec3D();
        Vec3D p2 = new Vec3D();
        Vec3D t2 = new Vec3D();
        for (int i = 1; i <= narcs; i++) {
            angle += dtheta;
            final double sin = Math.sin(angle);
            final double cos = Math.cos(angle);

            tmp.set(o.xAxis).scaleSelf((float) (r * cos));
            p2.set(o.origin).addSelf(tmp);
            tmp.set(o.yAxis).scaleSelf((float) (r * sin));
            p2.addSelf(tmp);

            cps[index + 2] = new Vec4D(p2, 1);

            t2.set(o.xAxis).scaleSelf((float) -sin);
            tmp.set(o.yAxis).scaleSelf((float) cos);
            t2.addSelf(tmp);

            lineIntersect3D(p0, t0, p2, t2, p1, p1);

            cps[index + 1] = new Vec4D(p1, (float) w1);
            index += 2;
            if (i < narcs) {
                p0.set(p2);
                t0.set(t2);
            }
View Full Code Here


     * @return A NurbsCurve for a full-circle
     */
    public static NurbsCurve createFullCircleQuad7(Origin3D o, float r) {

        Vec4D[] cp = new Vec4D[7];
        cp[0] = new Vec4D(o.xAxis.scale(r), 1);
        cp[3] = cp[0].getInvertedXYZ();
        cp[6] = cp[0].copy();

        cp[1] = new Vec4D(o.yAxis.add(o.xAxis).scaleSelf(r), 0.5f);
        cp[4] = cp[1].getInvertedXYZ();

        cp[2] = new Vec4D(o.xAxis.getInverted().addSelf(o.yAxis).scaleSelf(r),
                0.5f);
        cp[5] = cp[2].getInvertedXYZ();

        for (int i = 0; i < 7; i++) {
            cp[i].addXYZSelf(o.origin);
View Full Code Here

     */
    public static NurbsCurve createFullCircleQuad9(Origin3D o, float r) {
        final float w = MathUtils.SQRT2 / 2;

        Vec4D[] cp = new Vec4D[9];
        cp[0] = new Vec4D(o.xAxis.scale(r), 1);
        cp[4] = cp[0].getInvertedXYZ();
        cp[8] = cp[0].copy();

        cp[1] = new Vec4D(o.xAxis.add(o.yAxis).scaleSelf(r), w);
        cp[5] = cp[1].getInvertedXYZ();

        cp[2] = new Vec4D(o.yAxis.scale(r), 1);
        cp[6] = cp[2].getInvertedXYZ();

        cp[3] = new Vec4D(o.xAxis.getInverted().addSelf(o.yAxis).scaleSelf(r),
                w);
        cp[7] = cp[3].getInvertedXYZ();

        for (int i = 0; i < 9; i++) {
            cp[i].addXYZSelf(o.origin);
View Full Code Here

            if (r == 0) {
                X.set(O);
            }
            X.normalize();
            a.dir.crossInto(X, Y);
            pij[0][j] = new Vec4D(pj[j]);
            P0 = pj[j].to3D();
            T0.set(Y);
            int index = 0;
            for (int i = 1; i <= narcs; i++) {
                tmp.set(X).scaleSelf((float) (r * cos[i]));
                P2.set(O).addSelf(tmp);
                tmp.set(Y).scaleSelf((float) (r * sin[i]));
                P2.addSelf(tmp);

                pij[index + 2][j] = new Vec4D(P2, pj[j].w);

                tmp.set(Y).scaleSelf((float) cos[i]);
                T2.set(X).scaleSelf((float) -sin[i]).addSelf(tmp);

                lineIntersect3D(P0, T0, P2, T2, tmp, tmp);
                pij[index + 1][j] = new Vec4D(tmp, (float) (wm * pj[j].w));

                index += 2;
                if (i < narcs) {
                    P0.set(P2);
                    T0.set(T2);
View Full Code Here

            if (r == 0) {
                X.set(O);
            }
            X.normalize();
            a.dir.crossInto(X, Y);
            pij[0][j] = new Vec4D(pj[j]);
            P0 = pj[j].to3D();
            T0.set(Y);
            int index = 0;
            for (int i = 1; i <= narcs; i++) {
                tmp.set(X).scaleSelf((float) (r * cos[i]));
                P2.set(O).addSelf(tmp);
                tmp.set(Y).scaleSelf((float) (r * sin[i]));
                P2.addSelf(tmp);

                pij[index + 2][j] = new Vec4D(P2, pj[j].w);

                tmp.set(Y).scaleSelf((float) cos[i]);
                T2.set(X).scaleSelf((float) -sin[i]).addSelf(tmp);

                lineIntersect3D(P0, T0, P2, T2, tmp, tmp);
                pij[index + 1][j] = new Vec4D(tmp, (float) (wm * pj[j].w));

                index += 2;
                if (i < narcs) {
                    P0.set(P2);
                    T0.set(T2);
View Full Code Here

     *            Radius of the semi-circle
     * @return A NurbsCurve for a semi-circle
     */
    public static NurbsCurve createSemiCircle(Origin3D o, float r) {
        Vec4D[] cp = new Vec4D[4];
        cp[0] = new Vec4D(o.xAxis.scale(r), 1);
        cp[3] = cp[0].getInvertedXYZ();
        cp[0].addXYZSelf(o.origin);
        cp[3].addXYZSelf(o.origin);
        cp[1] = new Vec4D(o.xAxis.add(o.yAxis).scaleSelf(r).addSelf(o.origin),
                0.5f);
        cp[2] = new Vec4D(o.xAxis.getInverted().addSelf(o.yAxis).scaleSelf(r)
                .addSelf(o.origin), 0.5f);

        float[] u = {
                0, 0, 0, 0.5f, 1, 1, 1
        };
View Full Code Here

        // http://books.google.co.uk/books?id=7dqY5dyAwWkC&pg=PA455&lpg=PA455
        // fixed Z handling (was wrong in original jgeom version)
        Vec4D[][] cps = new Vec4D[cpProj.length][cpTraj.length];
        for (int i = 0; i < cpProj.length; i++) {
            for (int j = 0; j < cpTraj.length; j++) {
                Vec4D cp = new Vec4D();
                cp.x = cpProj[i].x * cpTraj[j].x * alpha;
                cp.y = cpProj[i].y * cpTraj[j].y * alpha;
                cp.z = (cpProj[i].z + cpTraj[j].z) * alpha;
                cp.w = cpProj[i].w * cpTraj[j].w;
                cps[i][j] = cp;
View Full Code Here

                 * Change added 11/02/90 Steve Larkin : Have multiplied the term
                 * wcoord to the extrusion vector before adding to the curve
                 * coordinates. Not really sure this is the correct fix, but it
                 * works !
                 */
                Vec4D cp = new Vec4D();
                cp.x = curvePoints[i].x + j * extrude.x;
                cp.y = curvePoints[i].y + j * extrude.y;
                cp.z = curvePoints[i].z + j * extrude.z;
                cp.w = curvePoints[i].w;
                cpoints[i][j] = cp;
View Full Code Here

            final GMatrix lu = new GMatrix(n, n);
            a.computeLUD(lu, perm);

            final Vec4D[] cps = new Vec4D[n];
            for (int i = 0; i < cps.length; i++) {
                cps[i] = new Vec4D(0, 0, 0, 1);
            }

            // x-ccordinate
            final GVector b = new GVector(n);
            for (int j = 0; j < n; j++) {
View Full Code Here

            try {
                NurbsCurve curve = globalCurveInterpolation(tmp, uDegrees);
                r[l] = curve.getControlPoints();
            } catch (InterpolationException ex) {
                for (int i = 0; i < tmp.length; i++) {
                    r[l][i] = new Vec4D(tmp[i], 1);
                }
            }

        }

        Vec4D[][] cp = new Vec4D[n][m];
        tmp = new Vec3D[m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                tmp[j] = r[j][i].to3D();
            }
            try {
                NurbsCurve curve = globalCurveInterpolation(tmp, vDegrees);
                cp[i] = curve.getControlPoints();
            } catch (InterpolationException ex) {
                for (int j = 0; j < tmp.length; j++) {
                    cp[i][j] = new Vec4D(tmp[j], 1);
                }
            }
        }

        return new BasicNurbsSurface(new ControlNet(cp), u, v);
View Full Code Here

TOP

Related Classes of toxi.geom.Vec4D

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.