当前位置: 首页>>代码示例>>Java>>正文


Java Matrix4d类代码示例

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


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

示例1: AffineTransform3D

import javax.vecmath.Matrix4d; //导入依赖的package包/类
public AffineTransform3D(double[] coeficients) {
    matrix = new Matrix4d();  	
    if (coeficients.length==9) {
        matrix.set(new Matrix3d(coeficients));
    } else if (coeficients.length==12) {
        double[] extendedCoeficients = new double[16];
        for (int i=0; i<coeficients.length; ++i) {
            extendedCoeficients[i] = coeficients[i];
        }
        extendedCoeficients[12] = 0;
        extendedCoeficients[13] = 0;
        extendedCoeficients[14] = 0;
        extendedCoeficients[15] = 1;
        matrix.set(extendedCoeficients);
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:17,代码来源:AffineTransform3D.java

示例2: buildProfile

import javax.vecmath.Matrix4d; //导入依赖的package包/类
public static Prof buildProfile( Line3d oLine, Point3d cen ) {
	
	Matrix4d to2D = new Matrix4d();
	Vector3d c2 = oLine.dir(), c3 = new Vector3d();

	c2.normalize();

	c3.cross( c2, UP );

	to2D.setIdentity();
	to2D.setRow( 0, c3.x, c3.y, c3.z, 0 );
	to2D.setRow( 1, UP.x, UP.y, UP.z, 0 );
	to2D.setRow( 2, c2.x, c2.y, c2.z, 0 );

	{
		Point3d start = new Point3d( cen.x, 0, cen.z );
		to2D.transform( start );
		to2D.m03 = -start.x;
		to2D.m13 = -start.y;
		to2D.m23 = -start.z;
		to2D.m33 = 1;
	}

	Prof monotonic = new Prof(to2D, c2);
	return monotonic;
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:27,代码来源:Prof.java

示例3: inBounds

import javax.vecmath.Matrix4d; //导入依赖的package包/类
private boolean inBounds( Matrix4d mini, List<double[]> bounds ) {
	
	// mini matrix is in mini-mesh format: a translation from a 255^3 cube in the first quadrant
	// trans.offset is a transform from that space, into jme rendered space (cartesian in meters, around the origin)
	
	Matrix4d m = new Matrix4d();
	m.mul( Jme3z.fromMatrix ( trans.offset ), mini );
	
	for (Point2d p : Arrays.stream( cubeCorners ).map( c -> { 
			Point3d tmp = new Point3d();
			m.transform( c, tmp );
			return new Point2d(tmp.x, tmp.z);
		}).collect( Collectors.toList() ) ) { 
	
			for (double[] bound : bounds) {
				 if ( 
						 bound[0] < p.x && bound[1] > p.x &&
						 bound[2] < p.y && bound[3] > p.y )
					 return true;
			}
	}
	
	return false;
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:25,代码来源:MiniGen.java

示例4: writeTo

import javax.vecmath.Matrix4d; //导入依赖的package包/类
@Override
public void writeTo(VirtualInstanceCollection virtualInstanceCollection, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws UnsupportedEncodingException {
    String charSet = "UTF-8";
    JsonGenerator jg = Json.createGenerator(new OutputStreamWriter(entityStream, charSet));
    jg.writeStartArray();

    Matrix4d gM = new Matrix4d();
    gM.setIdentity();

    PartLink virtualRootPartLink = getVirtualRootPartLink(virtualInstanceCollection);
    List<PartLink> path = new ArrayList<>();
    path.add(virtualRootPartLink);
    InstanceBodyWriterTools.generateInstanceStreamWithGlobalMatrix(productService, path, gM, virtualInstanceCollection, new ArrayList<>(), jg);
    jg.writeEnd();
    jg.flush();
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:17,代码来源:VirtualInstanceCollectionMessageBodyWriter.java

示例5: combineTransformation

import javax.vecmath.Matrix4d; //导入依赖的package包/类
static Matrix4d combineTransformation(Matrix4d matrix, Vector3d translation, Vector3d rotation) {
    Matrix4d gM = new Matrix4d(matrix);
    Matrix4d m = new Matrix4d();

    m.setIdentity();
    m.setTranslation(translation);
    gM.mul(m);

    m.setIdentity();
    m.rotZ(rotation.z);
    gM.mul(m);

    m.setIdentity();
    m.rotY(rotation.y);
    gM.mul(m);

    m.setIdentity();
    m.rotX(rotation.x);
    gM.mul(m);

    return gM;
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:23,代码来源:InstanceBodyWriterTools.java

示例6: writeLeaf

import javax.vecmath.Matrix4d; //导入依赖的package包/类
private static void writeLeaf(List<PartLink> currentPath, List<Integer> copyInstanceIds, PartIteration partI, Matrix4d combinedMatrix, JsonGenerator jg) {
    String partIterationId = partI.toString();
    List<InstanceAttributeDTO> attributes = new ArrayList<>();
    for (InstanceAttribute attr : partI.getInstanceAttributes()) {
        attributes.add(mapper.map(attr, InstanceAttributeDTO.class));
    }

    jg.writeStartObject();
    jg.write("id", Tools.getPathInstanceAsString(currentPath, copyInstanceIds));
    jg.write("partIterationId", partIterationId);
    jg.write("path", Tools.getPathAsString(currentPath));

    writeMatrix(combinedMatrix, jg);
    writeGeometries(partI.getSortedGeometries(), jg);
    writeAttributes(attributes, jg);

    jg.writeEnd();
    jg.flush();
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:20,代码来源:InstanceBodyWriterTools.java

示例7: set

import javax.vecmath.Matrix4d; //导入依赖的package包/类
public Matrix4 set(Matrix4d mat) {

        m00 = mat.m00;
        m01 = mat.m01;
        m02 = mat.m02;
        m03 = mat.m03;
        m10 = mat.m10;
        m11 = mat.m11;
        m12 = mat.m12;
        m13 = mat.m13;
        m20 = mat.m20;
        m21 = mat.m21;
        m22 = mat.m22;
        m23 = mat.m23;
        m30 = mat.m30;
        m31 = mat.m31;
        m32 = mat.m32;
        m33 = mat.m33;

        return this;
    }
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:22,代码来源:Matrix4.java

示例8: mul

import javax.vecmath.Matrix4d; //导入依赖的package包/类
/**
     * Multiply this transform by t1. This transform will be update
     * and the result returned
     * 
     * @param transform
     * @return this
     */
    public CellTransform mul(CellTransform in) {
        // This does not work when scale!=1
//        this.scale *= in.scale;
//        this.translation.addLocal(rotation.mult(in.translation).multLocal(in.scale));
//        this.rotation.multLocal(in.rotation);

        // Correctly calculate the multiplication.
        Quat4d q = new Quat4d(rotation.x, rotation.y, rotation.z, rotation.w);
        Vector3d t = new Vector3d(translation.x, translation.y, translation.z);
        Matrix4d m = new Matrix4d(q,t,scale);

        Quat4d q1 = new Quat4d(in.rotation.x, in.rotation.y, in.rotation.z, in.rotation.w);
        Vector3d t1 = new Vector3d(in.translation.x, in.translation.y, in.translation.z);
        Matrix4d m1 = new Matrix4d(q1,t1,in.scale);

        m.mul(m1);

        m.get(q);
        m.get(t);
        scale = (float)m.getScale();
        rotation.set((float)q.x, (float)q.y, (float)q.z, (float)q.w);
        translation.set((float)t.x, (float)t.y, (float)t.z);

        return this;
    }
 
开发者ID:josmas,项目名称:openwonderland,代码行数:33,代码来源:CellTransform.java

示例9: getDoubleBuffer

import javax.vecmath.Matrix4d; //导入依赖的package包/类
static public DoubleBuffer getDoubleBuffer(final Matrix4d matrix) {
	final DoubleBuffer result = DoubleBuffer.allocate(16);
	result.put(0, matrix.m00);
	result.put(1, matrix.m01);
	result.put(2, matrix.m02);
	result.put(3, matrix.m03);
	result.put(4, matrix.m10);
	result.put(5, matrix.m11);
	result.put(6, matrix.m12);
	result.put(7, matrix.m13);
	result.put(8, matrix.m20);
	result.put(9, matrix.m21);
	result.put(10, matrix.m22);
	result.put(11, matrix.m23);
	result.put(12, matrix.m30);
	result.put(13, matrix.m31);
	result.put(14, matrix.m32);
	result.put(15, matrix.m33);
	return result;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:21,代码来源:GeomMathUtils.java

示例10: getDoubleArray

import javax.vecmath.Matrix4d; //导入依赖的package包/类
static public double[] getDoubleArray(final Matrix4d matrix) {
	final double[] result = new double[16];
	result[0] = matrix.m00;
	result[1] = matrix.m01;
	result[2] = matrix.m02;
	result[3] = matrix.m03;
	result[4] = matrix.m10;
	result[5] = matrix.m11;
	result[6] = matrix.m12;
	result[7] = matrix.m13;
	result[8] = matrix.m20;
	result[9] = matrix.m21;
	result[10] = matrix.m22;
	result[11] = matrix.m23;
	result[12] = matrix.m30;
	result[13] = matrix.m31;
	result[14] = matrix.m32;
	result[15] = matrix.m33;
	return result;
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:21,代码来源:GeomMathUtils.java

示例11: rotate

import javax.vecmath.Matrix4d; //导入依赖的package包/类
/**
 * Make rotate input vector with Yaw(Z),Pitch(Y) and Roll(X) unreal rotation
 * values in the YXZ UT Editor coordinate system.
 * +00576.000000,+01088.000000,+00192.000000 ->
 * -00192.000000,+00064.000000,+00192.000000
 * 
 * @param v
 * @param pitch
 *            Pitch in Unreal Value (65536 u.v. = 360°)
 * @param yaw
 *            Yaw
 * @param roll
 * @return
 */
public static Vector3d rotate(Vector3d v, double pitch, double yaw, double roll) {

	pitch = UE12AngleToDegree(pitch);
	yaw = UE12AngleToDegree(yaw);
	roll = UE12AngleToDegree(roll);

	// TODO only divide by 360 if rotation values comes from Unreal Engine
	// 1/2
	double rot_x = ((roll) / 360D) * 2D * Math.PI; // Roll=Axis X with
													// Unreal Editor
	double rot_y = (((pitch)) / 360D) * 2D * Math.PI; // Pitch=Axis Y with
														// Unreal Editor
	double rot_z = ((yaw) / 360D) * 2D * Math.PI; // Yaw=Axis Z with Unreal
													// Editor

	double tmp[] = new double[] { v.x, v.y, v.z, 1D };
	Matrix4d m4d = getGlobalRotationMatrix(rot_x, rot_y, rot_z);

	tmp = getRot(tmp, m4d);
	v.x = tmp[0];
	v.y = tmp[1];
	v.z = tmp[2];

	return v;
}
 
开发者ID:xtremexp,项目名称:UT4Converter,代码行数:40,代码来源:Geometry.java

示例12: getGlobalRotationMatrix

import javax.vecmath.Matrix4d; //导入依赖的package包/类
/**
 * 
 * @param rot_x
 * @param rot_y
 * @param rot_z
 * @return
 */
private static Matrix4d getGlobalRotationMatrix(double rot_x, double rot_y, double rot_z) {
	Matrix4d m4d;

	// Checked
	Matrix4d m4d_x = new Matrix4d(1D, 0D, 0D, 0D, 0D, Math.cos(rot_x), -Math.sin(rot_x), 0D, 0D, Math.sin(rot_x), Math.cos(rot_x), 0D, 0D, 0D, 0D, 1D);

	// Checked
	Matrix4d m4d_y = new Matrix4d(Math.cos(rot_y), 0D, Math.sin(rot_y), 0D, 0D, 1D, 0D, 0D, -Math.sin(rot_y), 0, Math.cos(rot_y), 0D, 0D, 0D, 0D, 1D);

	// Checked
	Matrix4d m4d_z = new Matrix4d(Math.cos(rot_z), Math.sin(rot_z), 0D, 0D, -Math.sin(rot_z), Math.cos(rot_z), 0D, 0D, 0D, 0D, 1D, 0D, 0D, 0D, 0D, 1D);
	m4d_x = updateMatrix(m4d_x);
	m4d_y = updateMatrix(m4d_y);
	m4d_z = updateMatrix(m4d_z);

	m4d = m4d_x;
	m4d.mul(m4d_y);
	m4d.mul(m4d_z);

	return m4d;
}
 
开发者ID:xtremexp,项目名称:UT4Converter,代码行数:29,代码来源:Geometry.java

示例13: getRot

import javax.vecmath.Matrix4d; //导入依赖的package包/类
private static double[] getRot(double[] d2, Matrix4d m4d) {
	double d[] = new double[] { d2[0], d2[1], d2[2], 1D };

	double dx = m4d.m00 * d[0] + m4d.m10 * d[1] + m4d.m20 * d[2] + m4d.m30 * d[3];

	double dy = m4d.m01 * d[0] + m4d.m11 * d[1] + m4d.m21 * d[2] + m4d.m31 * d[3];
	double dz = m4d.m02 * d[0] + m4d.m12 * d[1] + m4d.m22 * d[2] + m4d.m32 * d[3];

	if (Math.abs(dx) < 0.00001D) {
		dx = 0D;
	}
	if (Math.abs(dy) < 0.00001D) {
		dy = 0D;
	}
	if (Math.abs(dz) < 0.00001D) {
		dz = 0D;
	}

	return new double[] { dx, dy, dz };
}
 
开发者ID:xtremexp,项目名称:UT4Converter,代码行数:21,代码来源:Geometry.java

示例14: TrackballRenderingViewer

import javax.vecmath.Matrix4d; //导入依赖的package包/类
public TrackballRenderingViewer( CameraController.Viewer delegate )
{
	this .delegate = delegate;
	
	this .translation = new Vector3d();
	Matrix4d matrix = new Matrix4d();
	Camera defaultCamera = new Camera();
	defaultCamera .setMagnification( 1.0f );
	defaultCamera .getViewTransform( matrix, 0d );
	matrix .get( translation ); // save the default translation to apply on every update below

	// set the perspective view just once
	double near = defaultCamera .getNearClipDistance();
       double far = defaultCamera .getFarClipDistance();
       double fov = defaultCamera .getFieldOfView();
	this .delegate .setPerspective( fov, 1.0d, near, far );
}
 
开发者ID:vZome,项目名称:vzome-desktop,代码行数:18,代码来源:TrackballRenderingViewer.java

示例15: Java2dExporter

import javax.vecmath.Matrix4d; //导入依赖的package包/类
/**
 * @param v[]
 * @param colors
 * @param lights
 * @param model
 */
public Java2dExporter( Camera view, Colors colors, Lights lights, RenderedModel model )
{
    super( view, colors, lights, model );
    
    this .view = view;
    Matrix4d viewMatrix = new Matrix4d();
    this .view .getViewTransform( viewMatrix, 0d );
    this .viewTransform = new Transform3D( viewMatrix );
    
    for ( int i = 0; i < lightDirs.length; i++ ) {
        lightDirs[ i ] = new Vector3f();
        // the next line fills in the direction, as well as returning the color... bad style!
        lightColors[ i ] = new Color( mLights .getDirectionalLight( i, lightDirs[ i ] ) .getRGB() );
        // the lights stay fixed relative to the viewpoint, so we must not apply the view transform
        lightDirs[ i ] .normalize();
        lightDirs[ i ] .negate();
    }
    ambientLight = new Color( mLights .getAmbientColor() .getRGB() );

}
 
开发者ID:vZome,项目名称:vzome-desktop,代码行数:27,代码来源:Java2dExporter.java


注:本文中的javax.vecmath.Matrix4d类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。