Java 类javax.vecmath.Point4f 实例源码
项目:PhET
文件:Jvxl.java
static Point4f getPlane(String str) {
if (str.equalsIgnoreCase("xy"))
return new Point4f(0, 0, 1, 0);
if (str.equalsIgnoreCase("xz"))
return new Point4f(0, 1, 0, 0);
if (str.equalsIgnoreCase("yz"))
return new Point4f(1, 0, 0, 0);
if (str.indexOf("x=") == 0) {
return new Point4f(1, 0, 0, -Parser.parseFloat(str.substring(2)));
}
if (str.indexOf("y=") == 0) {
return new Point4f(0, 1, 0, -Parser.parseFloat(str.substring(2)));
}
if (str.indexOf("z=") == 0) {
return new Point4f(0, 0, 1, -Parser.parseFloat(str.substring(2)));
}
if (str.indexOf("{") == 0) {
str = str.replace(',', ' ');
int[] next = new int[1];
return new Point4f(Parser.parseFloat(str, next), Parser.parseFloat(str,
next), Parser.parseFloat(str, next), Parser.parseFloat(str, next));
}
return null;
}
项目:PhET
文件:ScriptVariable.java
static public boolean isVariableType(Object x) {
return (x instanceof ScriptVariable
|| x instanceof BitSet
|| x instanceof Boolean
|| x instanceof Float
|| x instanceof Integer
|| x instanceof Point3f // stored as point3f
|| x instanceof Vector3f // stored as point3f
|| x instanceof Point4f // stored as point4f
|| x instanceof Quaternion // stored as point4f
|| x instanceof String
|| x instanceof Map<?, ?> // stored as Map<String, ScriptVariable>
|| x instanceof List<?> // stored as list
|| x instanceof ScriptVariable[] // stored as list
|| x instanceof double[] // stored as list
|| x instanceof float[] // stored as list
|| x instanceof Float[] // stored as list
|| x instanceof int[] // stored as list
|| x instanceof int[][] // stored as list
|| x instanceof Point4f[] // stored as list
|| x instanceof String[]); // stored as list
}
项目:PhET
文件:ScriptMathProcessor.java
private Point4f planeValue(Token x) {
if (isSyntaxCheck)
return new Point4f();
switch (x.tok) {
case Token.point4f:
return (Point4f) x.value;
case Token.varray:
case Token.string:
Object pt = Escape.unescapePoint(ScriptVariable.sValue(x));
return (pt instanceof Point4f ? (Point4f) pt : null);
case Token.bitset:
// ooooh, wouldn't THIS be nice!
break;
}
return null;
}
项目:PhET
文件:ScriptMathProcessor.java
private boolean evaluatePoint(ScriptVariable[] args) {
if (args.length != 1 && args.length != 3 && args.length != 4)
return false;
switch (args.length) {
case 1:
if (args[0].tok == Token.decimal || args[0].tok == Token.integer)
return addX(Integer.valueOf(ScriptVariable.iValue(args[0])));
Object pt = Escape.unescapePoint(ScriptVariable.sValue(args[0]));
if (pt instanceof Point3f)
return addX((Point3f) pt);
return addX("" + pt);
case 3:
return addX(new Point3f(ScriptVariable.fValue(args[0]), ScriptVariable
.fValue(args[1]), ScriptVariable.fValue(args[2])));
case 4:
return addX(new Point4f(ScriptVariable.fValue(args[0]), ScriptVariable
.fValue(args[1]), ScriptVariable.fValue(args[2]), ScriptVariable
.fValue(args[3])));
}
return false;
}
项目:PhET
文件:ScriptMathProcessor.java
@SuppressWarnings("unchecked")
protected static Quaternion[] getQuaternionArray(Object quaternionOrSVData) {
Quaternion[] data;
if (quaternionOrSVData instanceof Quaternion[]) {
data = (Quaternion[]) quaternionOrSVData;
} else if (quaternionOrSVData instanceof Point4f[]) {
Point4f[] pts = (Point4f[]) quaternionOrSVData;
data = new Quaternion[pts.length];
for (int i = 0; i < pts.length; i++)
data[i] = new Quaternion(pts[i]);
} else if (quaternionOrSVData instanceof List<?>) {
List<ScriptVariable> sv = (ArrayList<ScriptVariable>) quaternionOrSVData;
data = new Quaternion[sv.size()];
for (int i = 0; i < sv.size(); i++) {
Point4f pt = ScriptVariable.pt4Value(sv.get(i));
if (pt == null)
return null;
data[i] = new Quaternion(pt);
}
} else {
return null;
}
return data;
}
项目:PhET
文件:VolumeData.java
public void capData(Point4f plane, float cutoff) {
if (voxelData == null)
return;
int nx = voxelCounts[0];
int ny = voxelCounts[1];
int nz = voxelCounts[2];
Vector3f normal = new Vector3f(plane.x, plane.y, plane.z);
normal.normalize();
float f = 1f;
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++)
for (int z = 0; z < nz; z++) {
float value = voxelData[x][y][z] - cutoff;
voxelPtToXYZ(x, y, z, ptXyzTemp);
float d = (ptXyzTemp.x * normal.x + ptXyzTemp.y * normal.y + ptXyzTemp.z * normal.z + plane.w - cutoff) / f;
if (d >= 0 || d > value)
voxelData[x][y][z] = d;
}
}
项目:PhET
文件:IsoFxyzReader.java
@Override
protected void setup() {
functionName = (String) params.functionXYinfo.get(0);
jvxlFileHeaderBuffer = new StringBuffer();
jvxlFileHeaderBuffer.append("functionXYZ\n").append(functionName).append("\n");
volumetricOrigin.set((Point3f) params.functionXYinfo.get(1));
for (int i = 0; i < 3; i++) {
Point4f info = (Point4f) params.functionXYinfo.get(i + 2);
voxelCounts[i] = Math.abs((int) info.x);
volumetricVectors[i].set(info.y, info.z, info.w);
}
if (isAnisotropic)
setVolumetricAnisotropy();
data = (float[][][]) params.functionXYinfo.get(5);
JvxlCoder.jvxlCreateHeaderWithoutTitleOrAtoms(volumeData, jvxlFileHeaderBuffer);
}
项目:PhET
文件:IsoFxyReader.java
@Override
protected void setup() {
isPlanarMapping = (params.thePlane != null || params.state == Parameters.STATE_DATA_COLORED);
functionName = (String) params.functionXYinfo.get(0);
jvxlFileHeaderBuffer = new StringBuffer();
jvxlFileHeaderBuffer.append("functionXY\n").append(functionName).append("\n");
volumetricOrigin.set((Point3f) params.functionXYinfo.get(1));
for (int i = 0; i < 3; i++) {
Point4f info = (Point4f) params.functionXYinfo.get(i + 2);
voxelCounts[i] = Math.abs((int) info.x);
volumetricVectors[i].set(info.y, info.z, info.w);
}
if (isAnisotropic)
setVolumetricAnisotropy();
data = (float[][]) params.functionXYinfo.get(5);
JvxlCoder.jvxlCreateHeaderWithoutTitleOrAtoms(volumeData, jvxlFileHeaderBuffer);
}
项目:PhET
文件:IsoSolventReader.java
@Override
protected void generateCube() {
// This is the starting point for the calculation.
volumeData.getYzCount();
if (isCavity && params.theProperty != null)
return;
Logger.startTimer();
getMaxRadius();
if (isCavity && dataType != Parameters.SURFACE_NOMAP
&& dataType != Parameters.SURFACE_PROPERTY) {
volumeData.voxelData = voxelData = new float[nPointsX][nPointsY][nPointsZ];
resetVoxelData(Float.MAX_VALUE);
markSphereVoxels(cavityRadius, params.distance);
generateSolventCavity();
resetVoxelData(Float.MAX_VALUE);
markSphereVoxels(0, Float.NaN);
} else {
generateSolventCube();
}
unsetVoxelData();
if (params.cappingObject instanceof Point4f) {
volumeData.capData((Point4f) params.cappingObject, params.cutoff);
params.cappingObject = null;
}
Logger.checkTimer("solvent surface time");
}
项目:PhET
文件:MarchingSquares.java
/**
*
* @param surfaceReader
* @param volumeData
* @param thePlane NOT USED
* @param contoursDiscrete
* @param nContours
* @param thisContour
* @param contourFromZero
*/
public MarchingSquares(VertexDataServer surfaceReader, VolumeData volumeData,
Point4f thePlane, float[] contoursDiscrete, int nContours,
int thisContour, boolean contourFromZero) {
this.surfaceReader = surfaceReader;
this.volumeData = volumeData;
this.thisContour = thisContour;
this.contoursDiscrete = contoursDiscrete;
this.contourFromZero = contourFromZero; // really just a stand-in for "!fullPlane" //set false for MEP to complete the plane
if (contoursDiscrete == null) {
int i = 0;// DEAD CODE (true ? 0 : contourFromZero ? 1 : is3DContour ? 1 : 2);
nContourSegments = (nContours == 0 ? defaultContourCount : nContours) + i;
if (nContourSegments > nContourMax)
nContourSegments = nContourMax;
} else {
nContours = contoursDiscrete.length;
nContourSegments = nContours;
this.contourFromZero = false;
}
}
项目:PhET
文件:MolecularOrbital.java
private boolean getSettings(String strID) {
thisModel = htModels.get(strID);
if (thisModel == null || thisModel.get("moNumber") == null)
return false;
moTranslucency = (String) thisModel.get("moTranslucency");
moTranslucentLevel = (Float) thisModel.get("moTranslucentLevel");
moPlane = (Point4f) thisModel.get("moPlane");
moCutoff = (Float) thisModel.get("moCutoff");
if (moCutoff == null)
moCutoff = (Float) sg.getMoData().get("defaultCutoff");
if (moCutoff == null) {
moCutoff = new Float(Parameters.defaultQMOrbitalCutoff);
}
thisModel.put("moCutoff", new Float(moCutoff.floatValue()));
moResolution = (Float) thisModel.get("moResolution");
moScale = (Float) thisModel.get("moScale");
moColorPos = (Integer) thisModel.get("moColorPos");
moColorNeg = (Integer) thisModel.get("moColorNeg");
moNumber = ((Integer) thisModel.get("moNumber")).intValue();
moLinearCombination = (float[]) thisModel.get("moLinearCombination");
Object b = thisModel.get("moIsPositiveOnly");
moIsPositiveOnly = (b != null && ((Boolean) (b)).booleanValue());
return true;
}
项目:PhET
文件:Measure.java
public static boolean isInTetrahedron(Point3f pt, Point3f ptA, Point3f ptB,
Point3f ptC, Point3f ptD,
Point4f plane, Vector3f vTemp,
Vector3f vTemp2, Vector3f vTemp3, boolean fullyEnclosed) {
getPlaneThroughPoints(ptC, ptD, ptA, vTemp, vTemp2, vTemp3, plane);
boolean b = (distanceToPlane(plane, pt) >= 0);
getPlaneThroughPoints(ptA, ptD, ptB, vTemp, vTemp2, vTemp3, plane);
if (b != (distanceToPlane(plane, pt) >= 0))
return false;
getPlaneThroughPoints(ptB, ptD, ptC, vTemp, vTemp2, vTemp3, plane);
if (b != (distanceToPlane(plane, pt) >= 0))
return false;
getPlaneThroughPoints(ptA, ptB, ptC, vTemp, vTemp2, vTemp3, plane);
float d = distanceToPlane(plane, pt);
if (fullyEnclosed)
return (b == (d >= 0));
float d1 = distanceToPlane(plane, ptD);
return d1 * d <= 0 || Math.abs(d1) > Math.abs(d);
}
项目:PhET
文件:Escape.java
public static Object unescapePoint(String strPoint) {
if (strPoint == null || strPoint.length() == 0)
return strPoint;
String str = strPoint.replace('\n', ' ').trim();
if (str.charAt(0) != '{' || str.charAt(str.length() - 1) != '}')
return strPoint;
float[] points = new float[5];
int nPoints = 0;
str = str.substring(1, str.length() - 1);
int[] next = new int[1];
for (; nPoints < 5; nPoints++) {
points[nPoints] = Parser.parseFloat(str, next);
if (Float.isNaN(points[nPoints])) {
if (next[0] >= str.length() || str.charAt(next[0]) != ',')
break;
next[0]++;
nPoints--;
}
}
if (nPoints == 3)
return new Point3f(points[0], points[1], points[2]);
if (nPoints == 4)
return new Point4f(points[0], points[1], points[2], points[3]);
return strPoint;
}
项目:PhET
文件:MeshSurface.java
public void slabPolygons(Object slabbingObject, boolean andCap) {
if (slabbingObject instanceof Point4f) {
getIntersection((Point4f) slabbingObject, null, 0, null, andCap, false);
return;
}
if (slabbingObject instanceof Point3f[]) {
Point4f[] faces = BoxInfo.getFacesFromCriticalPoints((Point3f[]) slabbingObject);
for (int i = 0; i < faces.length; i++)
getIntersection(faces[i], null, 0, null, andCap, false);
return;
}
if (slabbingObject instanceof Object[]) {
Object[] o = (Object[]) slabbingObject;
float distance = ((Float) o[0]).floatValue();
Point3f center = (Point3f) o[1];
getIntersection(null, center, distance, null, andCap, false);
}
}
项目:PhET
文件:Quaternion.java
/**
* Just a starting point.
* get average normal vector
* scale normal by average projection of vectors onto it
* create quaternion from this 3D projection
*
* @param ndata
* @return approximate average
*/
private static Quaternion simpleAverage(Quaternion[] ndata) {
Vector3f mean = new Vector3f(0, 0, 1);
// using the directed normal ensures that the mean is
// continually added to and never subtracted from
Vector3f v = ndata[0].getNormal();
mean.add(v);
for (int i = ndata.length; --i >= 0;)
mean.add(ndata[i].getNormalDirected(mean));
mean.sub(v);
mean.normalize();
float f = 0;
// the 3D projection of the quaternion is [sin(theta/2)]*n
// so dotted with the normalized mean gets us an approximate average for sin(theta/2)
for (int i = ndata.length; --i >= 0;)
f += Math.abs(ndata[i].get3dProjection(v).dot(mean));
if (f != 0)
mean.scale(f / ndata.length);
// now convert f to the corresponding cosine instead of sine
f = (float) Math.sqrt(1 - mean.lengthSquared());
if (Float.isNaN(f))
f = 0;
return new Quaternion(new Point4f(mean.x, mean.y, mean.z, f));
}
项目:PhET
文件:Mesh.java
public void initialize(int lighting, Point3f[] vertices, Point4f plane) {
if (vertices == null)
vertices = this.vertices;
Vector3f[] normals = getNormals(vertices, plane);
normixes = new short[normixCount];
isTwoSided = (lighting == JmolConstants.FULLYLIT);
BitSet bsTemp = new BitSet();
if (haveXyPoints)
for (int i = normixCount; --i >= 0;)
normixes[i] = Graphics3D.NORMIX_NULL;
else
for (int i = normixCount; --i >= 0;)
normixes[i] = Graphics3D.getNormix(normals[i], bsTemp);
this.lighting = JmolConstants.FRONTLIT;
if (insideOut)
invertNormixes();
setLighting(lighting);
}
项目:PhET
文件:Mesh.java
public Vector3f[] getNormals(Point3f[] vertices, Point4f plane) {
normixCount = (isPolygonSet ? polygonCount : vertexCount);
Vector3f[] normals = new Vector3f[normixCount];
for (int i = normixCount; --i >= 0;)
normals[i] = new Vector3f();
if (plane == null) {
sumVertexNormals(vertices, normals);
}else {
Vector3f normal = new Vector3f(plane.x, plane.y, plane.z);
for (int i = normixCount; --i >= 0;)
normals[i] = normal;
}
if (!isPolygonSet)
for (int i = normixCount; --i >= 0;)
normals[i].normalize();
return normals;
}
项目:PhET
文件:ModelCollection.java
/**
*
* @param type
* @param plane
* @param scale
* @param modelIndex
* @param flags
* 1 -- edges only 2 -- triangles only 3 -- both
* @return Vector
*/
public List<Object> getPlaneIntersection(int type, Point4f plane, float scale,
int flags, int modelIndex) {
Point3f[] pts = null;
switch (type) {
case Token.unitcell:
SymmetryInterface uc = getUnitCell(modelIndex);
if (uc == null)
return null;
pts = uc.getCanonicalCopy(scale);
break;
case Token.boundbox:
pts = boxInfo.getCanonicalCopy(scale);
break;
}
List<Object> v = new ArrayList<Object>();
v.add(pts);
return TriangleData.intersectPlane(plane, v, flags);
}
项目:PhET
文件:_PovrayExporter.java
@Override
protected void outputCone(Point3f screenBase, Point3f screenTip,
float radius, short colix, boolean isBarb) {
if (isBarb) {
if (!haveMacros)
writeMacros2();
Point4f plane = new Point4f();
tempP1.set(screenBase.x, screenTip.y, 12345.6789f);
Measure.getPlaneThroughPoints(screenBase, screenTip, tempP1, tempV1,
tempV2, tempV3, plane);
output("barb(" + triad(screenBase) + "," + radius + ","
+ triad(screenTip) + ",0" + "," + color4(colix) + "," + plane.x + ","
+ plane.y + "," + plane.z + "," + -plane.w + ")\n");
} else {
output("b(" + triad(screenBase) + "," + radius + "," + triad(screenTip)
+ ",0" + "," + color4(colix) + ")\n");
}
}
项目:vzome-desktop
文件:Java2dExporter.java
/**
* Given a point in world coordinates, adjust it in place to be in
* screen coordinates (after projection).
*
* @param point
*/
public void mapWorldToScreen( Camera view, Point3f point )
{
Matrix4d viewMatrix = new Matrix4d();
this .view .getViewTransform( viewMatrix, 0d );
Transform3D viewTrans = new Transform3D( viewMatrix );
viewTrans .transform( point );
// point is now in view coordinates
Vector4f p4 = new Vector4f( point.x, point.y, point.z, 1f );
Transform3D eyeTrans = new Transform3D();
if ( ! view .isPerspective() ) {
double edge = view .getWidth() / 2;
eyeTrans .ortho( -edge, edge, -edge, edge, view .getNearClipDistance(), view .getFarClipDistance() );
}
else
eyeTrans .perspective( view .getFieldOfView(), 1.0d, view .getNearClipDistance(), view .getFarClipDistance() );
// TODO - make aspect ratio track the screen window shape
eyeTrans .transform( p4 );
point .project( new Point4f( p4 ) );
}
项目:vzome-desktop
文件:Java2dExporter.java
/**
* Given a point in world coordinates, adjust it in place to be in
* screen coordinates (after projection).
*
* @param point
*/
public void mapWorldToScreen( Camera view, Point3f point )
{
Matrix4d viewMatrix = new Matrix4d();
this .view .getViewTransform( viewMatrix, 0d );
Transform3D viewTrans = new Transform3D( viewMatrix );
viewTrans .transform( point );
// point is now in view coordinates
Vector4f p4 = new Vector4f( point.x, point.y, point.z, 1f );
Transform3D eyeTrans = new Transform3D();
if ( ! view .isPerspective() ) {
double edge = view .getWidth() / 2;
eyeTrans .ortho( -edge, edge, -edge, edge, view .getNearClipDistance(), view .getFarClipDistance() );
}
else
eyeTrans .perspective( view .getFieldOfView(), 1.0d, view .getNearClipDistance(), view .getFarClipDistance() );
// TODO - make aspect ratio track the screen window shape
eyeTrans .transform( p4 );
point .project( new Point4f( p4 ) );
}
项目:NK-VirtualGlobe
文件:DebugFrustumCullStage.java
/**
* Create a basic instance of this class with the list initial internal
* setup for the given number of renderable surfaces. The size is just an
* initial esstimate, and is used for optimisation purposes to prevent
* frequent array reallocations internally. As such, the number does not
* have to be perfect, just good enough.
*
* @param numSurfaces Total number of surfaces to prepare rendering for
* @param useGlobalView The rendered viewpoint is set to look down on the
* entire scene if set true, otherwise uses the normal value
*/
public DebugFrustumCullStage(int numSurfaces, boolean useGlobalView)
{
super(numSurfaces);
viewMatrix = new Matrix4f();
prjMatrix = new Matrix4f();
frustumPoints = new Point4f[8];
for(int i=0; i < 8; i++)
frustumPoints[i] = new Point4f();
frustumPlanes = new Vector4f[6];
for(int i=0; i < 6; i++)
frustumPlanes[i] = new Vector4f();
t1 = new float[3];
t2 = new float[3];
c1 = new float[3];
c2 = new float[3];
globalViewpoint = useGlobalView;
}
项目:NK-VirtualGlobe
文件:FrustumCullStage.java
/**
* Create a basic instance of this class with the list initial internal
* setup for the given number of renderable surfaces. The size is just an
* initial estimate, and is used for optimisation purposes to prevent
* frequent array reallocations internally. As such, the number does not
* have to be perfect, just good enough.
*
* @param numSurfaces Total number of surfaces to prepare rendering for
*/
public FrustumCullStage(int numSurfaces)
{
super(numSurfaces);
cullInstructions = new CullInstructions();
renderInstructions = new RenderableInstructions();
prjMatrix = new Matrix4f();
viewMatrix = new Matrix4f();
frustumPoints = new Point4f[8];
for(int i=0; i < 8; i++)
frustumPoints[i] = new Point4f();
frustumPlanes = new Vector4f[6];
for(int i=0; i < 6; i++)
frustumPlanes[i] = new Vector4f();
globalLightList = new EffectRenderable[LIGHT_START_SIZE];
globalLightTxList = new float[LIGHT_START_SIZE][16];
globalBoundedLightList = new EffectRenderable[LIGHT_START_SIZE];
globalBoundedLightTxList = new float[LIGHT_START_SIZE][16];
}
项目:NK-VirtualGlobe
文件:BoundingBox.java
/**
* The default constructor with the sphere radius as one and
* center at the origin.
*/
public BoundingBox()
{
min = new Point3f();
max = new Point4f();
center = new float[3];
size = new float[3];
vert = new float[8][];
xvert = new float[8][];
for ( int i = 0; i < 8; i++ )
{
vert[i] = new float[3];
xvert[i] = new float[3];
}
max.w = 0;
}
项目:PhET
文件:ScriptEvaluator.java
private Point4f hklParameter(int i) throws ScriptException {
if (!isSyntaxCheck && viewer.getCurrentUnitCell() == null)
error(ERROR_noUnitCell);
Point3f pt = (Point3f) getPointOrPlane(i, false, true, false, true, 3, 3);
Point4f p = getHklPlane(pt);
if (p == null)
error(ERROR_badMillerIndices);
if (!isSyntaxCheck && Logger.debugging)
Logger.info("defined plane: " + p);
return p;
}
项目:PhET
文件:ScriptEvaluator.java
protected Point4f getHklPlane(Point3f pt) {
Vector3f vAB = new Vector3f();
Vector3f vAC = new Vector3f();
Point3f pt1 = new Point3f(pt.x == 0 ? 1 : 1 / pt.x, 0, 0);
Point3f pt2 = new Point3f(0, pt.y == 0 ? 1 : 1 / pt.y, 0);
Point3f pt3 = new Point3f(0, 0, pt.z == 0 ? 1 : 1 / pt.z);
// trick for 001 010 100 is to define the other points on other edges
if (pt.x == 0 && pt.y == 0 && pt.z == 0) {
return null;
} else if (pt.x == 0 && pt.y == 0) {
pt1.set(1, 0, pt3.z);
pt2.set(0, 1, pt3.z);
} else if (pt.y == 0 && pt.z == 0) {
pt2.set(pt1.x, 0, 1);
pt3.set(pt1.x, 1, 0);
} else if (pt.z == 0 && pt.x == 0) {
pt3.set(0, pt2.y, 1);
pt1.set(1, pt2.y, 0);
} else if (pt.x == 0) {
pt1.set(1, pt2.y, 0);
} else if (pt.y == 0) {
pt2.set(0, 1, pt3.z);
} else if (pt.z == 0) {
pt3.set(pt1.x, 0, 1);
}
// base this one on the currently defined unit cell
viewer.toCartesian(pt1, false);
viewer.toCartesian(pt2, false);
viewer.toCartesian(pt3, false);
Vector3f plane = new Vector3f();
float w = Measure.getNormalThroughPoints(pt1, pt2, pt3, plane, vAB, vAC);
return new Point4f(plane.x, plane.y, plane.z, w);
}
项目:PhET
文件:ScriptEvaluator.java
private Quaternion getQuaternionParameter(int i) throws ScriptException {
if (tokAt(i) == Token.varray) {
List<ScriptVariable> sv = ((ScriptVariable) getToken(i)).getList();
Point4f p4 = null;
if (sv.size() == 0
|| (p4 = ScriptVariable.pt4Value(sv.get(0))) == null)
error(ERROR_invalidArgument);
return new Quaternion(p4);
}
return new Quaternion(getPoint4f(i));
}
项目:PhET
文件:ScriptVariable.java
public static float fValue(Token x) {
switch (x == null ? nada : x.tok) {
case on:
return 1;
case off:
return 0;
case integer:
return x.intValue;
case decimal:
return ((Float) x.value).floatValue();
case varray:
int i = x.intValue;
if (i == Integer.MAX_VALUE)
return ((ScriptVariable)x).getList().size();
case string:
return toFloat(sValue(x));
case bitset:
return iValue(x);
case point3f:
return ((Point3f) x.value).distance(pt0);
case point4f:
return Measure.distanceToPlane((Point4f) x.value, pt0);
case matrix3f:
Point3f pt = new Point3f();
((Matrix3f) x.value).transform(pt);
return pt.distance(pt0);
case matrix4f:
Point3f pt1 = new Point3f();
((Matrix4f) x.value).transform(pt1);
return pt1.distance(pt0);
default:
return 0;
}
}
项目:PhET
文件:ScriptVariable.java
public static Point4f pt4Value(ScriptVariable x) {
switch (x.tok) {
case point4f:
return (Point4f) x.value;
case string:
Object o = Escape.unescapePoint((String) x.value);
if (!(o instanceof Point4f))
break;
return (Point4f) o;
}
return null;
}
项目:PhET
文件:ScriptVariable.java
public static boolean areEqual(ScriptVariable x1, ScriptVariable x2) {
if (x1.tok == string && x2.tok == string)
return sValue(x1).equalsIgnoreCase(
sValue(x2));
if (x1.tok == point3f && x2.tok == point3f)
return (((Point3f) x1.value).distance((Point3f) x2.value) < 0.000001);
if (x1.tok == point4f && x2.tok == point4f)
return (((Point4f) x1.value).distance((Point4f) x2.value) < 0.000001);
return (Math.abs(fValue(x1)
- fValue(x2)) < 0.000001);
}
项目:PhET
文件:JvxlData.java
public void setSurfaceInfo(Point4f thePlane, int nSurfaceInts, String surfaceData) {
jvxlSurfaceData = surfaceData;
if (jvxlSurfaceData.indexOf("--") == 0)
jvxlSurfaceData = jvxlSurfaceData.substring(2);
jvxlPlane = thePlane;
this.nSurfaceInts = nSurfaceInts;
}
项目:PhET
文件:VolumeData.java
public void setDataDistanceToPlane(Point4f plane) {
setPlaneParameters(plane);
int nx = voxelCounts[0];
int ny = voxelCounts[1];
int nz = voxelCounts[2];
voxelData = new float[nx][ny][nz];
for (int x = 0; x < nx; x++)
for (int y = 0; y < ny; y++)
for (int z = 0; z < nz; z++)
voxelData[x][y][z] = calcVoxelPlaneDistance(x, y, z);
}
项目:PhET
文件:Parameters.java
void setPlane(Point4f plane) {
thePlane = plane;
if (thePlane.x == 0 && thePlane.y == 0
&& thePlane.z == 0)
thePlane.z = 1; //{0 0 0 w} becomes {0 0 1 w}
isContoured = true;
}
项目:PhET
文件:Parameters.java
void setSphere(float radius) {
dataType = SURFACE_SPHERE;
distance = radius;
setEccentricity(new Point4f(0, 0, 1, 1));
cutoff = Float.MIN_VALUE;
isCutoffAbsolute = false;
isSilent = !logMessages;
script = getScriptParams() + " SPHERE " + radius + ";";
}
项目:PhET
文件:Parameters.java
void setEllipsoid(Point4f v) {
dataType = SURFACE_ELLIPSOID2;
distance = 1f;
setEccentricity(v);
cutoff = Float.MIN_VALUE;
isCutoffAbsolute = false;
isSilent = !logMessages;
//script = " center " + Escape.escape(center)
// + (Float.isNaN(scale) ? "" : " scale " + scale) + " ELLIPSOID {" + v.x
//+ " " + v.y + " " + v.z + " " + v.w + "};";
}
项目:PhET
文件:Parameters.java
void setLobe(Point4f v) {
dataType = SURFACE_LOBE;
setEccentricity(v);
if (cutoff == Float.MAX_VALUE) {
cutoff = defaultOrbitalCutoff;
if (isSquared)
cutoff = cutoff * cutoff;
}
isSilent = !logMessages;
script = getScriptParams() + " LOBE {" + v.x + " "
+ v.y + " " + v.z + " " + v.w + "};";
}
项目:PhET
文件:Parameters.java
void setLp(Point4f v) {
dataType = SURFACE_LONEPAIR;
setEccentricity(v);
if (cutoff == Float.MAX_VALUE) {
cutoff = defaultOrbitalCutoff;
if (isSquared)
cutoff = cutoff * cutoff;
}
isSilent = !logMessages;
script = " center " + Escape.escape(center)
+ (Float.isNaN(scale) ? "" : " scale " + scale) + " LP {" + v.x + " "
+ v.y + " " + v.z + " " + v.w + "};";
}
项目:PhET
文件:Parameters.java
void setRadical(Point4f v) {
dataType = SURFACE_RADICAL;
setEccentricity(v);
if (cutoff == Float.MAX_VALUE) {
cutoff = defaultOrbitalCutoff;
if (isSquared)
cutoff = cutoff * cutoff;
}
isSilent = !logMessages;
script = " center " + Escape.escape(center)
+ (Float.isNaN(scale) ? "" : " scale " + scale) + " RAD {" + v.x + " "
+ v.y + " " + v.z + " " + v.w + "};";
}
项目:PhET
文件:IsosurfaceMesh.java
Point4f getFacePlane(int i, Vector3f vNorm) {
Point4f plane = new Point4f();
Measure.getPlaneThroughPoints(vertices[polygonIndexes[i][0]],
vertices[polygonIndexes[i][1]], vertices[polygonIndexes[i][2]],
vNorm, vAB, vAC, plane);
return plane;
}
项目:PhET
文件:Isosurface.java
private void getClosestPoint(IsosurfaceMesh m, int imin, Point3f toPt, Point3f ptRet,
Vector3f normalRet) {
Point4f plane = m.getFacePlane(imin, normalRet);
float dist = Measure.distanceToPlane(plane, toPt);
normalRet.scale(-dist);
ptRet.set(toPt);
ptRet.add(normalRet);
dist = Measure.distanceToPlane(plane, ptRet);
if (m.centers[imin].distance(toPt) < ptRet.distance(toPt))
ptRet.set(m.centers[imin]);
}