本文整理汇总了Java中javax.vecmath.Matrix4d.transform方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix4d.transform方法的具体用法?Java Matrix4d.transform怎么用?Java Matrix4d.transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.vecmath.Matrix4d
的用法示例。
在下文中一共展示了Matrix4d.transform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: rotateVectorAroundAxis
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Rotate by angle around vector axis. Thumb of right hand in same direction as
* axis vector and closing palm shows direction of rotation.
* @param vector
* @param axis
* @param angle angle in degrees
*/
public static Location rotateVectorAroundAxis(Location vector, Location axis, double angle) {
// move eye stuff back
double x = axis.x;
double y = axis.y;
double z = axis.z;
double radianAngle = angle * Math.PI / 180;
double c = Math.cos(radianAngle);
double s = Math.sin(radianAngle);
/*
( xx(1-c)+c xy(1-c)-zs xz(1-c)+ys 0 )
| yx(1-c)+zs yy(1-c)+c yz(1-c)-xs 0 |
| xz(1-c)-ys yz(1-c)+xs zz(1-c)+c 0 |
( 0 0 0 1 )
*/
Matrix4d rotateMatrix = new Matrix4d(
x * x * (1 - c) + c, x * y * (1 - c) - z * s, x * z * (1 - c) + y * s, 0,
y * x * (1 - c) + z * s, y * y * (1 - c) + c, y * z * (1 - c) - x * s, 0,
x * z * (1 - c) - y * s, y * z * (1 - c) + x * s, z * z * (1 - c) + c, 0,
0, 0, 0, 1);
Vector3d vec = new Vector3d(vector.x, vector.y, vector.z);
rotateMatrix.transform(vec);
return new Location(vec.x, vec.y, vec.z);
}
示例3: buildFrame
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
private Matrix4d buildFrame( Vector3f[] locs ) {
Vector3f dir0 = new Vector3f(locs[1]);
dir0 = dir0.subtract(locs[0]);
dir0.y = 0;
// dir.normalize();
Vector3f dir1 = new Vector3f(0,dir0.length(),0);
Vector3f dir2 = new Vector3f(-dir0.z, 0, dir0.x);
Matrix4d out = new Matrix4d();
out.setRow( 0, toArray( dir2 ));
out.setRow( 1, toArray( dir1 ));
out.setRow( 2, toArray( dir0 ));
out.m03 = locs[0].x;
out.m13 = 0;
out.m23 = locs[0].z;
out.m33 = 1;
if (false)
{
Point3d a = new Point3d (0,0,0);
Point3d b = new Point3d (0,0,1);
out.transform( a );
out.transform( b );
System.out.println( a + " >>><<< " + b );
System.out.println( locs[0] + " <<<>>> " + locs[1] );
}
return out;
}
示例4: transform
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public static Loop<LPoint3d> transform( Loop<? extends LPoint3d> ll, Matrix4d mat ) {
Loop<LPoint3d> out = new Loop<>();
for (LPoint3d p : ll) {
LPoint3d pn = new LPoint3d(p, p.label);
mat.transform( pn );
out.append( pn );
}
return out;
}
示例5: setBounds
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public void setBounds( Matrix4d to2d, FRect bounds ) {
List<Point2d> envelop = new ArrayList<>();
for (int i = 0; i < 4; i++) {
Point3d tmp = new Point3d(corners[i]);
to2d.transform( tmp );
envelop.add( Pointz.to2( tmp ) );
}
bounds.setFrom( new DRectangle( envelop ) );
}
示例6: locTrans
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
private float[] locTrans(int[] fs, Matrix4d viewMatrix) {
Vector4d loc =new Vector4d(
Math.floor( ( fs[0] ) + 0.5),
Math.floor( ( fs[1] ) + 0.5),
Math.floor( ( fs[2] ) + 0.5),
1);
viewMatrix.transform(loc);
return new float[] { (float) loc.x, (float) loc.y , (float) loc.z};
}
示例7: trackballRolled
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public void trackballRolled( Quat4d roll )
{
mViewPlatform .getWorldRotation( roll );
Matrix4d rollM = new Matrix4d();
rollM.set( roll );
// roll is now a rotation in world coordinates
rollM.transform( zoneVector3d );
mapVectorToAxis();
}
示例8: getWorldRotation
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public void getWorldRotation( Quat4d q )
{
Vector3d axis = new Vector3d( q.x, q.y, q.z );
Matrix4d viewTrans = new Matrix4d();
model .getViewTransform( viewTrans, 0d );
viewTrans .invert();
// now map the axis back to world coordinates
viewTrans .transform( axis );
q.x = axis.x; q.y = axis.y; q.z = axis.z;
}
示例9: mapViewToWorld
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public void mapViewToWorld( Vector3f vector )
{
Matrix4d viewTrans = new Matrix4d();
model .getViewTransform( viewTrans, 0d );
viewTrans .invert();
viewTrans .transform( vector );
}
示例10: transform
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/** returns a copy of this quad with the given transformation applied */
public RawQuad transform(Matrix4d matrix)
{
RawQuad result = this.clone();
// transform vertices
for(int i = 0; i < result.vertexCount; i++)
{
Vertex vertex = result.getVertex(i);
Vector4d temp = new Vector4d(vertex.x, vertex.y, vertex.z, 1.0);
matrix.transform(temp);
if(Math.abs(temp.w - 1.0) > 1e-5) temp.scale(1.0 / temp.w);
result.setVertex(i, vertex.withXYZ(temp.x, temp.y, temp.z));
}
// transform nominal face
// our matrix transform has block center as its origin,
// so need to translate face vectors to/from block center
// origin before/applying matrix.
if(this.face != null)
{
Vec3i curNorm = this.face.getDirectionVec();
Vector4d newFaceVec = new Vector4d(curNorm.getX() + 0.5, curNorm.getY() + 0.5, curNorm.getZ() + 0.5, 1.0);
matrix.transform(newFaceVec);
newFaceVec.x -= 0.5;
newFaceVec.y -= 0.5;
newFaceVec.z -= 0.5;
result.setFace(QuadHelper.computeFaceForNormal(newFaceVec));
}
return result;
}
示例11: mapViewToWorld
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
public void mapViewToWorld( Camera view, Vector3f vector )
{
Matrix4d viewTrans = new Matrix4d();
view .getViewTransform( viewTrans, 0d );
viewTrans .invert();
viewTrans .transform( vector );
}
示例12: transform
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Transforms an atom object, given a Matrix4d (i.e. the vecmath library
* double-precision 4x4 rotation+translation matrix). The transformation
* Matrix must be a post-multiplication Matrix.
*
* @param atom
* @param m
*/
public static final void transform(Atom atom, Matrix4d m) {
Point3d p = new Point3d(atom.getX(), atom.getY(), atom.getZ());
m.transform(p);
atom.setX(p.x);
atom.setY(p.y);
atom.setZ(p.z);
}
示例13: transform
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Transform the current postion by the given transformation matrix.
*
* @param mat The matrix to transform this bounds by
*/
public void transform(Matrix4d mat)
{
min.x = center[0];
min.y = center[1];
min.z = center[2];
max.x = size[0];
max.y = size[1];
max.z = size[2];
mat.transform(min);
mat.transform(max);
center[0] = min.x;
center[1] = min.y;
center[2] = min.z;
size[0] = Math.abs(max.x);
size[1] = Math.abs(max.y);
size[2] = Math.abs(max.z);
min.x = center[0] - size[0];
min.y = center[1] - size[1];
min.z = center[2] - size[2];
max.x = center[0] + size[0];
max.y = center[1] + size[1];
max.z = center[2] + size[2];
}
示例14: intersect
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
@Override
public final void intersect(final Ray ray, final IntersectResult result,
final double tMin, final double tMax) {
final Ray transformedRay = new Ray(ray);
if (transform != null) {
final Matrix4d mInv = transform.getMinv();
mInv.transform(transformedRay.eyePoint);
transformedRay.viewDirection = (Vector3d) ray.viewDirection.clone();
mInv.transform(transformedRay.viewDirection);
}
final IntersectResult subResult = new IntersectResult();
IntersectResult closestResult = null;
// Find closest intersection
for (final AbstractSurfaceXml surf : children) {
surf.intersect(transformedRay, subResult, tMin, tMax);
if (subResult.p != null
&& (result.p == null || subResult.tIn < result.tIn)) {
closestResult = subResult;
}
}
// Set result to closest intersection
if (closestResult != null) {
final IntersectResult transformedResult = new IntersectResult();
transformedResult.set(closestResult);
if (transform != null) {
final Matrix4d m = transform.getM();
m.transform(transformedResult.p);
final Matrix4d transposed = new Matrix4d();
transposed.transpose(m);
transposed.invert();
transposed.transform(transformedResult.n);
transformedResult.n.normalize();
}
result.set(transformedResult);
if (material != null) {
result.material = material;
}
}
}
示例15: buildOrigin
import javax.vecmath.Matrix4d; //导入方法依赖的package包/类
/**
* Transform toCartesian (around x,y) to a renderable coordinate system with y-up.
*/
private Matrix4d buildOrigin( double x, double y, MathTransform toCartesian ) throws TransformException {
double delta = 1e-6;
double[] frame = new double[] {
x , y,
x+delta, y,
x , y+delta,
0 , 0 ,0 };
toCartesian.transform( frame, 0, frame, 0, 3 );
Vector3d o = new Vector3d(frame[0], frame[1], frame[2]),
a = new Vector3d(frame[3], frame[4], frame[5]),
b = new Vector3d(frame[6], frame[7], frame[8]),
c = new Vector3d();
a.sub( o );
b.sub( o );
a.normalize();
b.normalize();
c.cross( a, b );
Matrix4d out = new Matrix4d();
out.setRow( 0, -a.x, -a.y, -a.z, 0 );
out.setRow( 1, c.x, c.y, c.z, 0 );
out.setRow( 2, b.x, b.y, b.z, 0 );
out.setRow( 3, 0, 0, 0, 1 );
out.transform( o );
out.m03 = -o.x;
out.m13 = -o.y;
out.m23 = -o.z;
return out;
}