本文整理汇总了Java中javax.vecmath.Vector3f.cross方法的典型用法代码示例。如果您正苦于以下问题:Java Vector3f.cross方法的具体用法?Java Vector3f.cross怎么用?Java Vector3f.cross使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.vecmath.Vector3f
的用法示例。
在下文中一共展示了Vector3f.cross方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillNormal
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
/**
* internal, relies on fixed format of FaceBakery
*/
public static void fillNormal(int[] faceData, EnumFacing facing)
{
Vector3f v1 = new Vector3f(faceData[3 * 7 + 0], faceData[3 * 7 + 1], faceData[3 * 7 + 2]);
Vector3f t = new Vector3f(faceData[1 * 7 + 0], faceData[1 * 7 + 1], faceData[1 * 7 + 2]);
Vector3f v2 = new Vector3f(faceData[2 * 7 + 0], faceData[2 * 7 + 1], faceData[2 * 7 + 2]);
v1.sub(t);
t.set(faceData[0 * 7 + 0], faceData[0 * 7 + 1], faceData[0 * 7 + 2]);
v2.sub(t);
v1.cross(v2, v1);
v1.normalize();
int x = ((byte)(v1.x * 127)) & 0xFF;
int y = ((byte)(v1.y * 127)) & 0xFF;
int z = ((byte)(v1.z * 127)) & 0xFF;
for(int i = 0; i < 4; i++)
{
faceData[i * 7 + 6] = x | (y << 0x08) | (z << 0x10);
}
}
示例2: orth
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
private static Vector3f orth(Vector3f v, Vector3f out) {
Vector3f a = Stack.alloc(Vector3f.class);
a.set(0f, 0f, 1f);
a.cross(v, a);
Vector3f b = Stack.alloc(Vector3f.class);
b.set(0f, 1f, 0f);
b.cross(v, b);
if (a.length() > b.length()) {
out.normalize(a);
return out;
}
else {
out.normalize(b);
return out;
}
}
示例3: renderLonePair
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
private void renderLonePair(boolean isRadical) {
pt2f.set(imesh.vertices[1]);
viewer.transformPoint(pt2f, pt2f);
int r = viewer.scaleToScreen((int)pt2f.z, 100);
if (r < 1)
r = 1;
if (!isRadical) {
Vector3f v1 = new Vector3f();
Vector3f v2 = new Vector3f();
pt1f.set(imesh.vertices[0]);
viewer.transformPoint(pt1f, pt1f);
v1.sub(pt2f, pt1f);
v2.set(v1.x, v1.y, v1.z + 1);
v2.cross(v2,v1);
v2.normalize();
float f = viewer.scaleToScreen((int)pt1f.z, 100);
v2.scale(f);
pt1f.set(pt2f);
pt1f.add(v2);
pt2f.sub(v2);
screens[0].set((int)pt1f.x,(int)pt1f.y,(int)pt1f.z);
g3d.fillSphere(r, screens[0]);
}
screens[1].set((int)pt2f.x,(int)pt2f.y,(int)pt2f.z);
g3d.fillSphere(r, screens[1]);
}
示例4: triNormal
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
private static Vector3f triNormal(Vector3f v0, Vector3f v1, Vector3f v2, Vector3f out) {
Vector3f tmp1 = Stack.alloc(Vector3f.class);
Vector3f tmp2 = Stack.alloc(Vector3f.class);
// return the normal of the triangle
// inscribed by v0, v1, and v2
tmp1.sub(v1, v0);
tmp2.sub(v2, v1);
Vector3f cp = Stack.alloc(Vector3f.class);
cp.cross(tmp1, tmp2);
float m = cp.length();
if (m == 0) {
out.set(1f, 0f, 0f);
return out;
}
out.scale(1f / m, cp);
return out;
}
示例5: getNormal
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
public Normal getNormal()
{
Vector3f a = this.verts[2].getPos3();
a.sub(this.verts[0].getPos3());
Vector3f b = this.verts[3].getPos3();
b.sub(this.verts[1].getPos3());
a.cross(a, b);
a.normalize();
return new Normal(a);
}
示例6: getNormal
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
public static Vector3f getNormal(Vertex v1, Vertex v2, Vertex v3)
{
Vector3f a = new Vector3f(v2.getPos());
a.sub(v1.getPos());
Vector3f b = new Vector3f(v3.getPos());
b.sub(v1.getPos());
Vector3f c = new Vector3f();
c.cross(a, b);
c.normalize();
return c;
}
示例7: GetCoordinates
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
public Vector3f GetCoordinates(Face face, Vector3f out) {
Vector3f tmp = Stack.alloc(Vector3f.class);
Vector3f tmp1 = Stack.alloc(Vector3f.class);
Vector3f tmp2 = Stack.alloc(Vector3f.class);
Vector3f o = Stack.alloc(Vector3f.class);
o.scale(-face.d, face.n);
float[] a = floatArrays.getFixed(3);
tmp1.sub(face.v[0].w, o);
tmp2.sub(face.v[1].w, o);
tmp.cross(tmp1, tmp2);
a[0] = tmp.length();
tmp1.sub(face.v[1].w, o);
tmp2.sub(face.v[2].w, o);
tmp.cross(tmp1, tmp2);
a[1] = tmp.length();
tmp1.sub(face.v[2].w, o);
tmp2.sub(face.v[0].w, o);
tmp.cross(tmp1, tmp2);
a[2] = tmp.length();
float sm = a[0] + a[1] + a[2];
out.set(a[1], a[2], a[0]);
out.scale(1f / (sm > 0f ? sm : 1f));
floatArrays.release(a);
return out;
}
示例8: rotateToXYZ
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
private Vector3f rotateToXYZ(Vector3f p) {
Vector3f axe = new Vector3f();
Vector3f n = new Vector3f(info.getPlaneNormal());
n.normalize();
Vector3f XYnormal = new Vector3f(0, 0, 1);
axe.cross(n, XYnormal);
axe.normalize();
double angle = Math.acos(n.dot(XYnormal));
Vector3f tmp = rotateAroundAxe(p, axe, -angle);
tmp.add(info.getPlanePoint());
return tmp;
}
示例9: updateWheelTransform
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
public void updateWheelTransform(int wheelIndex, boolean interpolatedTransform) {
WheelInfo wheel = wheelInfo.getQuick(wheelIndex);
updateWheelTransformsWS(wheel, interpolatedTransform);
Vector3f up = Stack.alloc(Vector3f.class);
up.negate(wheel.raycastInfo.wheelDirectionWS);
Vector3f right = wheel.raycastInfo.wheelAxleWS;
Vector3f fwd = Stack.alloc(Vector3f.class);
fwd.cross(up, right);
fwd.normalize();
// up = right.cross(fwd);
// up.normalize();
// rotate around steering over de wheelAxleWS
float steering = wheel.steering;
Quat4f steeringOrn = Stack.alloc(Quat4f.class);
QuaternionUtil.setRotation(steeringOrn, up, steering); //wheel.m_steering);
Matrix3f steeringMat = Stack.alloc(Matrix3f.class);
MatrixUtil.setRotation(steeringMat, steeringOrn);
Quat4f rotatingOrn = Stack.alloc(Quat4f.class);
QuaternionUtil.setRotation(rotatingOrn, right, -wheel.rotation);
Matrix3f rotatingMat = Stack.alloc(Matrix3f.class);
MatrixUtil.setRotation(rotatingMat, rotatingOrn);
Matrix3f basis2 = Stack.alloc(Matrix3f.class);
basis2.setRow(0, right.x, fwd.x, up.x);
basis2.setRow(1, right.y, fwd.y, up.y);
basis2.setRow(2, right.z, fwd.z, up.z);
Matrix3f wheelBasis = wheel.worldTransform.basis;
wheelBasis.mul(steeringMat, rotatingMat);
wheelBasis.mul(basis2);
wheel.worldTransform.origin.scaleAdd(wheel.raycastInfo.suspensionLength, wheel.raycastInfo.wheelDirectionWS, wheel.raycastInfo.hardPointWS);
}
示例10: findAxis
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
public static float findAxis(Point3f[] points, int nPoints, Point3f axisA,
Vector3f axisUnitVector, Vector3f vectorProjection) {
Vector3f sumXiYi = new Vector3f();
Vector3f vTemp = new Vector3f();
Point3f pt = new Point3f();
Point3f ptProj = new Point3f();
Vector3f a = new Vector3f(axisUnitVector);
float sum_Xi2 = 0;
float sum_Yi2 = 0;
for (int i = nPoints; --i >= 0;) {
pt.set(points[i]);
ptProj.set(pt);
projectOntoAxis(ptProj, axisA, axisUnitVector,
vectorProjection);
vTemp.sub(pt, ptProj);
sum_Yi2 += vTemp.lengthSquared();
vTemp.cross(vectorProjection, vTemp);
sumXiYi.add(vTemp);
sum_Xi2 += vectorProjection.lengthSquared();
}
Vector3f m = new Vector3f(sumXiYi);
m.scale(1 / sum_Xi2);
vTemp.cross(m, axisUnitVector);
axisUnitVector.add(vTemp);
axisUnitVector.normalize();
//check for change in direction by measuring vector difference length
vTemp.set(axisUnitVector);
vTemp.sub(a);
return vTemp.length();
}
示例11: setAtom2dZ
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
private static void setAtom2dZ(Atom atomRef, Atom atom2, Vector3f v, Vector3f v0, Vector3f v1) {
v.set(atom2);
v.sub(atomRef);
v.z = 0;
v.normalize();
v1.cross(v0, v);
double theta = Math.acos(v.dot(v0));
atom2.z = atomRef.z + (float) (0.8f * Math.sin(4 * theta));
}
示例12: computeFaceNormal
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
private void computeFaceNormal(List<Integer> ind, int polytype) {
Vector3f u = new Vector3f(model.getVerts().get(ind.get(1) - 1));
u.sub(model.getVerts().get(ind.get(0) - 1));
Vector3f v = new Vector3f(model.getVerts().get(ind.get(2) - 1));
v.sub(model.getVerts().get(ind.get(0) - 1));
u.cross(u, v);
u.negate();
for (int i = 0; i < polytype; i++) {
model.getNormals().get(ind.get(i) - 1).add(u);
}
}
示例13: evaluateCross
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
private boolean evaluateCross(ScriptVariable[] args) {
if (args.length != 2)
return false;
ScriptVariable x1 = args[0];
ScriptVariable x2 = args[1];
if (x1.tok != Token.point3f || x2.tok != Token.point3f)
return false;
Vector3f a = new Vector3f((Point3f) x1.value);
Vector3f b = new Vector3f((Point3f) x2.value);
a.cross(a, b);
return addX(new Point3f(a));
}
示例14: setDepth
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
private void setDepth(Vector3f depth, Point3f c, Point3f a, Point3f b, float ratio) {
T1.sub(a, c);
T1.scale(ratio);
T2.sub(a, b);
depth.cross(T1, T2);
depth.scale(T1.length() / depth.length());
}
示例15: isInside
import javax.vecmath.Vector3f; //导入方法依赖的package包/类
@Override
public boolean isInside(Vector3f pt, float tolerance) {
Vector3f normal = Stack.alloc(Vector3f.class);
calcNormal(normal);
// distance to plane
float dist = pt.dot(normal);
float planeconst = vertices1[0].dot(normal);
dist -= planeconst;
if (dist >= -tolerance && dist <= tolerance) {
// inside check on edge-planes
int i;
for (i = 0; i < 3; i++) {
Vector3f pa = Stack.alloc(Vector3f.class), pb = Stack.alloc(Vector3f.class);
getEdge(i, pa, pb);
Vector3f edge = Stack.alloc(Vector3f.class);
edge.sub(pb, pa);
Vector3f edgeNormal = Stack.alloc(Vector3f.class);
edgeNormal.cross(edge, normal);
edgeNormal.normalize();
/*float*/ dist = pt.dot(edgeNormal);
float edgeConst = pa.dot(edgeNormal);
dist -= edgeConst;
if (dist < -tolerance) {
return false;
}
}
return true;
}
return false;
}