• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java Matrix4x4类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中toxi.geom.Matrix4x4的典型用法代码示例。如果您正苦于以下问题:Java Matrix4x4类的具体用法?Java Matrix4x4怎么用?Java Matrix4x4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

Matrix4x4类属于toxi.geom包,在下文中一共展示了Matrix4x4类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getLibrariesFolder

点赞 3

import toxi.geom.Matrix4x4; //导入依赖的package包/类
public static String getLibrariesFolder() {
        // This is used, as Papart classes are often linked to another folder...
        URL main = Matrix4x4.class.getResource("Matrix4x4.class");
//        URL main = Papart.class.getResource("Papart.class");
        String tmp = main.getPath();
//        System.out.println("path  " + tmp);
        // its in a jar
        if (tmp.contains("!")) {
            tmp = tmp.substring(0, tmp.indexOf('!'));
            tmp = tmp.replace("file:", "");
            //        tmp = tmp.replace("file:/", "");  TODO: OS check ?
        }
        File f = new File(tmp);
        if (!f.exists()) {
            System.err.println("Error in loading the Sketchbook folder.");
        }
        // if the file is within a library/lib folder
        if (f.getParentFile().getAbsolutePath().endsWith("/lib")) {
            //     pathToSketchbook/libraries/myLib/library/lib/myLib.jar
            f = f.getParentFile().getParentFile().getParentFile().getParentFile();
        } else {
            //     pathToSketchbook/libraries/myLib/library/myLib.jar
            f = f.getParentFile().getParentFile().getParentFile();
        }
        return f.getAbsolutePath();
    }
 

开发者ID:poqudrof,
项目名称:PapARt,
代码行数:27,
代码来源:LibraryUtils.java

示例2: testRotate

点赞 3

import toxi.geom.Matrix4x4; //导入依赖的package包/类
public void testRotate() {
    Matrix4x4 m = new Matrix4x4();
    m.rotateX(MathUtils.HALF_PI);
    Vec3D v = m.applyTo(new Vec3D(0, 1, 0));
    assertTrue(new Vec3D(0, 0, 1).equalsWithTolerance(v, 0.00001f));
    m.identity();
    m.rotateY(MathUtils.HALF_PI);
    v = m.applyTo(new Vec3D(1, 0, 0));
    assertTrue(new Vec3D(0, 0, -1).equalsWithTolerance(v, 0.00001f));
    m.identity();
    m.rotateZ(MathUtils.HALF_PI);
    v = m.applyTo(new Vec3D(1, 0, 0));
    assertTrue(new Vec3D(0, 1, 0).equalsWithTolerance(v, 0.00001f));
    m.identity();
    m.rotateAroundAxis(new Vec3D(0, 1, 0), MathUtils.HALF_PI);
    v = m.applyTo(new Vec3D(1, 0, 0));
    assertTrue(new Vec3D(0, 0, 1).equalsWithTolerance(v, 0.00001f));
}
 

开发者ID:postspectacular,
项目名称:toxiclibs,
代码行数:19,
代码来源:MatrixTest.java

示例3: setup

点赞 3

import toxi.geom.Matrix4x4; //导入依赖的package包/类
public void setup() {
	super.setup();
	for(int i=0; i<boxes.length; i++) {
		// create a new direction vector for each box
		Vec3D dir=new Vec3D(cos(i*TWO_PI/75),sin(i*TWO_PI/50),sin(i*TWO_PI/25)).normalize();
		// create a position on a sphere, using the direction vector
		Vec3D pos=dir.scale(SCALE);
		// create a box mesh at the origin
		AABB boxxx = new AABB(new Vec3D(), BOX_SIZE);
		TriangleMesh b= (TriangleMesh)boxxx.toMesh();
		// align the Z axis of the box with the direction vector
		b.pointTowards(dir);
		// move the box to the correct position
		b.transform(new Matrix4x4().translateSelf(pos.x,pos.y,pos.z));
		boxes[i]=b;
	}
}
 

开发者ID:cacheflowe,
项目名称:haxademic,
代码行数:18,
代码来源:AlignObjectsToSphere.java

示例4: initMat

点赞 2

import toxi.geom.Matrix4x4; //导入依赖的package包/类
private void initMat() {
    float[] valuesFloat = new float[16];
    double[] valuesDouble = new double[16];
    pmatrix.get(valuesFloat);

    for (int i = 0; i < valuesFloat.length; i++) {
        valuesDouble[i] = (double) valuesFloat[i];
    }
    mat = new Matrix4x4(valuesDouble);
    invPmatrix = pmatrix.get();
    invPmatrix.invert();
}
 

开发者ID:poqudrof,
项目名称:PapARt,
代码行数:13,
代码来源:HomographyCalibration.java

示例5: transform

点赞 2

import toxi.geom.Matrix4x4; //导入依赖的package包/类
/**
 * Applies the given matrix transform to all mesh vertices. If the
 * updateNormals flag is true, all face normals are updated automatically,
 * however vertex normals need a manual update.
 * 
 * @param mat
 * @param updateNormals
 * @return itself
 */
public TriangleMesh transform(Matrix4x4 mat, boolean updateNormals) {
    for (Vertex v : vertices.values()) {
        v.set(mat.applyTo(v));
    }
    if (updateNormals) {
        computeFaceNormals();
    }
    return this;
}
 

开发者ID:postspectacular,
项目名称:toxiclibs,
代码行数:19,
代码来源:TriangleMesh.java

示例6: transform

点赞 2

import toxi.geom.Matrix4x4; //导入依赖的package包/类
/**
 * Applies the given matrix transform to all mesh vertices. If the
 * updateNormals flag is true, all face normals are updated automatically,
 * however vertex normals still need a manual update.
 * 
 * @param mat
 * @param updateNormals
 * @return itself
 */
public WETriangleMesh transform(Matrix4x4 mat, boolean updateNormals) {
    for (Vertex v : vertices.values()) {
        mat.applyToSelf(v);
    }
    rebuildIndex();
    if (updateNormals) {
        computeFaceNormals();
    }
    return this;
}
 

开发者ID:postspectacular,
项目名称:toxiclibs,
代码行数:20,
代码来源:WETriangleMesh.java

示例7: testInverse

点赞 2

import toxi.geom.Matrix4x4; //导入依赖的package包/类
public void testInverse() {
    Matrix4x4 m = new Matrix4x4();
    m.translateSelf(100, 100, 0);
    m.rotateX(MathUtils.HALF_PI);
    m.scaleSelf(10, 10, 10);
    System.out.println(m);
    Vec3D v = new Vec3D(0, 1, 0);
    Vec3D w = m.applyTo(v);
    m = m.getInverted();
    ReadonlyVec3D v2 = m.applyTo(w);
    System.out.println(w);
    System.out.println(v2);
    assertTrue(v2.equalsWithTolerance(v, 0.0001f));
}
 

开发者ID:postspectacular,
项目名称:toxiclibs,
代码行数:15,
代码来源:MatrixTest.java

示例8: testMatrixRoundtrip

点赞 2

import toxi.geom.Matrix4x4; //导入依赖的package包/类
public void testMatrixRoundtrip() {
    for (int i = 0; i < 1000; i++) {
        Quaternion q = Quaternion.createFromAxisAngle(Vec3D.randomVector(),
                MathUtils.random(MathUtils.TWO_PI)).normalize();
        Matrix4x4 m = q.toMatrix4x4();
        Quaternion q2 = Quaternion.createFromMatrix(m);
        Vec3D p = Vec3D.randomVector();
        Vec3D p2 = p.copy();
        q.applyTo(p);
        q2.applyTo(p2);
        // floats are not very kind to round tripping
        // hence quite large epsilon
        assertTrue(p.equalsWithTolerance(p2, 0.0001f));
    }
}
 

开发者ID:postspectacular,
项目名称:toxiclibs,
代码行数:16,
代码来源:QuaternionTest.java

示例9: getLibrariesFolder

点赞 2

import toxi.geom.Matrix4x4; //导入依赖的package包/类
static public String getLibrariesFolder() {

        // This is used, as Papart classes are often linked to another folder...
        URL main = Matrix4x4.class.getResource("Matrix4x4.class");
//        URL main = ARDisplay.class.getResource("ARDisplay.class");
        String tmp = main.getPath();

        System.out.println("path  " + tmp);

        // its in a jar
        if (tmp.contains("!")) {
            tmp = tmp.substring(0, tmp.indexOf('!'));
            tmp = tmp.replace("file:", "");
//        tmp = tmp.replace("file:/", "");  TODO: OS check ?
        }

        File f = new File(tmp);
        if (!f.exists()) {
            System.err.println("Error in loading the Sketchbook folder.");
        }

        // if the file is within a library/lib folder
        if (f.getParentFile().getAbsolutePath().endsWith(("/lib"))) {
            //     pathToSketchbook/libraries/myLib/library/lib/myLib.jar
            f = f.getParentFile().getParentFile().getParentFile().getParentFile();
        } else {
            //     pathToSketchbook/libraries/myLib/library/myLib.jar
            f = f.getParentFile().getParentFile().getParentFile();
        }

        return f.getAbsolutePath();
    }
 

开发者ID:poqudrof,
项目名称:PapAR,
代码行数:33,
代码来源:Utils.java

示例10: Boid

点赞 2

import toxi.geom.Matrix4x4; //导入依赖的package包/类
Boid(Vec3D l, float ms, float mf, float nd, float sep) {
	loc=l;
	acc = new Vec3D();
	vel = Vec3D.randomVector();
	mat = new Matrix4x4();
	maxspeed = ms;
	maxforce = mf;
	neighborDist=nd*nd;
	desiredSeparation=sep;
}
 

开发者ID:cacheflowe,
项目名称:haxademic,
代码行数:11,
代码来源:FlockingBoidsShiffmanToxi.java

示例11: getHomographyMat4x4

点赞 2

import toxi.geom.Matrix4x4; //导入依赖的package包/类
@Deprecated
public Matrix4x4 getHomographyMat4x4() {
    return mat;
}
 

开发者ID:poqudrof,
项目名称:PapARt,
代码行数:5,
代码来源:HomographyCalibration.java

示例12: flipYAxis

点赞 2

import toxi.geom.Matrix4x4; //导入依赖的package包/类
public TriangleMesh flipYAxis() {
    transform(new Matrix4x4().scaleSelf(1, -1, 1));
    flipVertexOrder();
    return this;
}
 

开发者ID:postspectacular,
项目名称:toxiclibs,
代码行数:6,
代码来源:TriangleMesh.java

示例13: testTranslate

点赞 2

import toxi.geom.Matrix4x4; //导入依赖的package包/类
public void testTranslate() {
    Matrix4x4 m = new Matrix4x4();
    m.translateSelf(100, 100, 100);
    assertEquals(new Vec3D(100, 100, 100), m.applyTo(new Vec3D()));
}
 

开发者ID:postspectacular,
项目名称:toxiclibs,
代码行数:6,
代码来源:MatrixTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)