Java 类javax.vecmath.Point3f 实例源码

项目:PhET    文件:__CartesianExporter.java   
protected Point3f getCameraPosition() {

    // used for VRML/X3D only

    Point3f ptCamera = new Point3f();
    Point3f pt = new Point3f(screenWidth / 2, screenHeight / 2, 0);
    viewer.unTransformPoint(pt, ptCamera);
    ptCamera.sub(center);
    // this is NOT QUITE correct when the model has been shifted with CTRL-ALT
    // because in that case the center of distortion is not the screen center,
    // and these simpler perspective models don't allow for that.
    tempP3.set(screenWidth / 2, screenHeight / 2, cameraDistance
        * scalePixelsPerAngstrom);
    viewer.unTransformPoint(tempP3, tempP3);
    tempP3.sub(center);
    ptCamera.add(tempP3);

    System.out.println(ptCamera + " " + cameraPosition);
    //  return ptCamera;

    return cameraPosition;

  }
项目:PhET    文件:RocketsRenderer.java   
void drawBox(Point3f pointA, Point3f pointB) {
  Sheet sheet = (Sheet)proteinstructurePending;
  float scale = mad / 1000f;
  scaledWidthVector.set(sheet.getWidthUnitVector());
  scaledWidthVector.scale(scale);
  scaledHeightVector.set(sheet.getHeightUnitVector());
  scaledHeightVector.scale(scale / 4);
  pointCorner.add(scaledWidthVector, scaledHeightVector);
  pointCorner.scaleAdd(-0.5f, pointA);
  lengthVector.sub(pointB, pointA);
  buildBox(pointCorner, scaledWidthVector,
           scaledHeightVector, lengthVector);
  for (int i = 0; i < 6; ++i) {
    int i0 = boxFaces[i * 4];
    int i1 = boxFaces[i * 4 + 1];
    int i2 = boxFaces[i * 4 + 2];
    int i3 = boxFaces[i * 4 + 3];
    g3d.fillQuadrilateral(screenCorners[i0],
                            screenCorners[i1],
                            screenCorners[i2],
                            screenCorners[i3]);
  }
}
项目:PhET    文件:PmeshReader.java   
protected boolean readVertices() throws Exception {
  pmeshError = type + " ERROR: vertex count must be positive";
  if (!isBinary)
    nVertices = getInt();
  if (onePerLine)
    iToken = Integer.MAX_VALUE;
  if (nVertices <= 0) {
    pmeshError += " (" + nVertices + ")";
    return false;
  }
  pmeshError = type + " ERROR: invalid vertex list";
  Point3f pt = new Point3f();
  vertexMap = new int[nVertices];
  for (int i = 0; i < nVertices; i++) {
    pt.set(getFloat(), getFloat(), getFloat());
    if (isAnisotropic)
      setVertexAnisotropy(pt);
    if (Logger.debugging)
      Logger.debug(i + ": " + pt);
    vertexMap[i] = addVertexCopy(pt, 0, i);
    if (onePerLine)
      iToken = Integer.MAX_VALUE;
  }
  pmeshError = null;
  return true;
}
项目:Analyst    文件:SymmetryPlane.java   
public void findLabralesFPs(){

    if (stomionFP == null) {
        return;
    }

    Point3f labraleSupCandidate = new Point3f(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
    Point3f labraleInfCandidate = new Point3f(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);

    for(Point3f symPoint : symmetryPlanePoints) {
        if (symPoint.y > stomionFP.getPosition().y && symPoint.y < stomionFP.getPosition().y + SEARCH_THRESHOLD) {
            if (symPoint.z > labraleSupCandidate.z)
                labraleSupCandidate = symPoint;
        } else if (symPoint.y < stomionFP.getPosition().y && symPoint.y > stomionFP.getPosition().y - SEARCH_THRESHOLD) {
            if (symPoint.z > labraleInfCandidate.z)
                labraleInfCandidate = symPoint;
        }
    }

    labraleSuperiusFP = new FacialPoint(FacialPointType.LS, labraleSupCandidate);
    labraleInferiusFP = new FacialPoint(FacialPointType.LI, labraleInfCandidate);

    facialPoints.add(labraleSuperiusFP);
    facialPoints.add(labraleInferiusFP);
}
项目:PhET    文件:_X3dExporter.java   
@Override
protected void outputTextPixel(Point3f pt, int argb) {
  // text only
  String color = rgbFractionalFromArgb(argb, ' ');
  output("<Transform translation='");
  output(pt);
  output("'>\n<Shape ");
  String child = useTable.getDef("p" + argb);
  if (child.charAt(0) == '_') {
    output("DEF='" + child + "'>");
    output("<Sphere radius='0.01'/>");
    output("<Appearance><Material diffuseColor='0 0 0' specularColor='0 0 0'"
      + " ambientIntensity='0.0' shininess='0.0' emissiveColor='" 
      + color + "'/></Appearance>'");
  } else {
    output(child + ">");
  }
  output("</Shape>\n");
  output("</Transform>\n");
}
项目:PhET    文件:__RayTracerExporter.java   
/**
 * 
 * @param screenA
 * @param screenB
 * @param madBond
 * @param colix
 * @param endcaps
 */
protected void fillConicalCylinder(Point3f screenA, Point3f screenB,
                                  int madBond, short colix, 
                                  byte endcaps) {
  float radius1 = viewer.scaleToScreen((int) screenA.z, madBond) / 2f;
  if (radius1 == 0)
    return;
  if (radius1 < 1)
    radius1 = 1;
  if (screenA.distance(screenB) == 0) {
    outputSphere(screenA.x, screenA.y, screenA.z, radius1, colix);
    return;
  }
  float radius2 = viewer.scaleToScreen((int) screenB.z, madBond) / 2f;
  if (radius2 == 0)
    return;
  if (radius2 < 1)
    radius2 = 1;
  outputCylinderConical(screenA, screenB, radius1, radius2, colix);
}
项目:PhET    文件:MeshData.java   
/**
 * Calculates the data (faces, vertices, normals) for a cone.
 * 
 * @return The data.
 */
static MeshSurface getConeData() {
  int ndeg = 10;
  int n = 360 / ndeg;
  Point3f[] vertices = new Point3f[n + 1];
  int[][] faces = new int[n][];
  for (int i = 0; i < n; i++)
    faces[i] = new int[] { i, (i + 1) % n, n };
  double d = ndeg / 180. * Math.PI;
  for (int i = 0; i < n; i++) {
    float x = (float) (Math.cos(i * d));
    float y = (float) (Math.sin(i * d));
    vertices[i] = new Point3f(x, y, 0);
  }
  vertices[n] = new Point3f(0, 0, 1);
  return new MeshSurface(faces, vertices, 0, vertices, 0);
}
项目:PhET    文件:__CartesianExporter.java   
protected Point3f getModelCenter() {
  // "center" is the center of rotation, not
  // necessary the screen center or the center of the model. 
  // When the user uses ALT-CTRL-drag, Jmol is applying an 
  // XY screen translation AFTER the matrix transformation. 
  // Apparently, that's unusual in this business. 
  // (The rotation center is generally directly
  // in front of the observer -- not allowing, for example,
  // holding the model in one's hand at waist level and rotating it.)

  // But there are good reasons to do it the Jmol way. If you don't, then
  // what happens is that the distortion pans over the moving model
  // and you get an odd lens effect rather than the desired smooth
  // panning. So we must approximate.

  return referenceCenter;
}
项目:PhET    文件:__CartesianExporter.java   
@Override
void drawCylinder(Point3f ptA, Point3f ptB, short colix1, short colix2,
                  byte endcaps, int mad, int bondOrder) {
  setTempPoints(ptA, ptB, bondOrder == -1);
  float radius = mad / 2000f;
  if (colix1 == colix2) {
    outputCylinder(null, tempP1, tempP2, colix1, endcaps, radius, null, null);
  } else {
    tempV2.set(tempP2);
    tempV2.add(tempP1);
    tempV2.scale(0.5f);
    tempP3.set(tempV2);
    outputCylinder(null, tempP1, tempP3, colix1,
        (endcaps == Graphics3D.ENDCAPS_SPHERICAL ? Graphics3D.ENDCAPS_NONE
            : endcaps), radius, null, null);
    outputCylinder(null, tempP3, tempP2, colix2,
        (endcaps == Graphics3D.ENDCAPS_SPHERICAL ? Graphics3D.ENDCAPS_NONE
            : endcaps), radius, null, null);
    if (endcaps == Graphics3D.ENDCAPS_SPHERICAL) {
      outputSphere(tempP1, radius * 1.01f, colix1);
      outputSphere(tempP2, radius * 1.01f, colix2);
    }
  }
}
项目:PhET    文件:_X3dExporter.java   
@Override
protected boolean outputCylinder(Point3f ptCenter, Point3f pt1, Point3f pt2,
                              short colix, byte endcaps, float radius, Point3f ptX, Point3f ptY) {
  output("<Transform");
  if (ptX == null) {
    outputTransRot(pt1, pt2, 0, 1, 0);
  } else {
    output(" translation='");
    output(ptCenter);
    output("'");
    outputQuaternionFrame(ptCenter, ptY, pt1, ptX, 2, "='", "'");
    pt1.set(0, 0, -1);
    pt2.set(0, 0, 1);
  }
  output(">\n");
  outputCylinderChild(pt1, pt2, colix, endcaps, radius);
  output("\n</Transform>\n");
  if (endcaps == Graphics3D.ENDCAPS_SPHERICAL) {
    outputSphere(pt1, radius * 1.01f, colix);
    outputSphere(pt2, radius * 1.01f, colix);
  }
  return true;
}
项目:PhET    文件:TransformManager.java   
private Point3i transformScreenPoint(Point3f ptXyp) {
  // just does the processing for [x y] and [x y %]
  if (ptXyp.z == -Float.MAX_VALUE) {
    point3iScreenTemp.x = (int) (ptXyp.x / 100 * screenWidth);
    point3iScreenTemp.y = (int) ((1 - ptXyp.y / 100) * screenHeight);
  } else {
    point3iScreenTemp.x = (int) ptXyp.x;
    point3iScreenTemp.y = (screenHeight - (int) ptXyp.y);
  }
  if (antialias) {
    point3iScreenTemp.x <<= 1;
    point3iScreenTemp.y <<= 1;
  }
  matrixTransform.transform(fixedRotationCenter, pointTsp);
  point3iScreenTemp.z = (int) pointTsp.z;
  return point3iScreenTemp;
}
项目:PhET    文件:Group.java   
/**
 * 
 * @param tokType
 * @param qType
 * @param mStep
 * @return helix data of some sort
 */
public Object getHelixData(int tokType, char qType, int mStep) {
      switch (tokType) {
      case Token.point:
        return new Point3f();
      case Token.axis:
      case Token.radius:
        return new Vector3f();
      case Token.angle:
        return new Float(Float.NaN);
      case Token.array:
      case Token.list:
        return new String[] {};
      }
  return "";
}
项目:PhET    文件:RocketsRenderer.java   
void buildArrowHeadBox(Point3f pointCorner, Vector3f scaledWidthVector,
                       Vector3f scaledHeightVector, Point3f pointTip) {
  for (int i = 4; --i >= 0; ) {
    Point3f corner = corners[i];
    corner.set(pointCorner);
    if ((i & 1) != 0)
      corner.add(scaledWidthVector);
    if ((i & 2) != 0)
      corner.add(scaledHeightVector);
    viewer.transformPoint(corner, screenCorners[i]);
  }
  corners[4].set(pointTip);
  viewer.transformPoint(pointTip, screenCorners[4]);
  corners[5].add(pointTip, scaledHeightVector);
  viewer.transformPoint(corners[5], screenCorners[5]);
}
项目:PhET    文件:VolumeData.java   
public float lookupInterpolatedVoxelValue(Point3f point) {
  if (sr != null) {
    float v = sr.getValueAtPoint(point);
    return (isSquared ? v * v : v);
  }
  ptXyzTemp.sub(point, volumetricOrigin);
  inverseMatrix.transform(ptXyzTemp);
  int iMax;
  int xDown = indexDown(ptXyzTemp.x, iMax = voxelCounts[0] - 1);
  int xUp = xDown + (ptXyzTemp.x < 0 || xDown == iMax ? 0 : 1);
  int yDown = indexDown(ptXyzTemp.y, iMax = voxelCounts[1] - 1);
  int yUp = yDown + (ptXyzTemp.y < 0 || yDown == iMax ? 0 : 1);
  int zDown = indexDown(ptXyzTemp.z, iMax = voxelCounts[2] - 1);
  int zUp = zDown + (ptXyzTemp.z < 0 || zDown == iMax ? 0 : 1);
  float v1 = getFractional2DValue(ptXyzTemp.x - xDown, ptXyzTemp.y - yDown,
      getVoxelValue(xDown, yDown, zDown), getVoxelValue(xUp, yDown, zDown),
      getVoxelValue(xDown, yUp, zDown), getVoxelValue(xUp, yUp, zDown));
  float v2 = getFractional2DValue(ptXyzTemp.x - xDown, ptXyzTemp.y - yDown,
      getVoxelValue(xDown, yDown, zUp), getVoxelValue(xUp, yDown, zUp),
      getVoxelValue(xDown, yUp, zUp), getVoxelValue(xUp, yUp, zUp));
  return v1 + (ptXyzTemp.z - zDown) * (v2 - v1);
}
项目:PhET    文件:Triangle3D.java   
void fillTriangle(Point3f screenA, Point3f screenB, Point3f screenC,
                  boolean useGouraud) {
  ax[0] = (int) screenA.x;
  ax[1] = (int) screenB.x;
  ax[2] = (int) screenC.x;
  ay[0] = (int) screenA.y;
  ay[1] = (int) screenB.y;
  ay[2] = (int) screenC.y;
  az[0] = (int) screenA.z;
  az[1] = (int) screenB.z;
  az[2] = (int) screenC.z;
  fillTriangle(useGouraud);
}
项目:PhET    文件:_ObjExporter.java   
@Override
protected void outputTextPixel(Point3f pt, int argb) {
  debugPrint("outputTextPixel");
  if (surfacesOnly) {
    debugPrint("  Not done owing to surfacesOnly");
    return;
  }

  short colix = Graphics3D.getColix(argb);
  outputSphere(pt, pixelSize, colix);
}
项目:PhET    文件:Measure.java   
public static float getTransformMatrix4(List<Point3f> ptsA, List<Point3f> ptsB, Matrix4f m, Point3f centerA) {
  Point3f[] cptsA = getCenterAndPoints(ptsA);
  Point3f[] cptsB = getCenterAndPoints(ptsB);
  float[] retStddev = new float[2];
  Quaternion q = calculateQuaternionRotation(new Point3f[][] { cptsA,
      cptsB }, retStddev, false);
  Vector3f v = new Vector3f(cptsB[0]);
  v.sub(cptsA[0]);
  m.set(q.getMatrix(), v, 1);
  if (centerA != null)
    centerA.set(cptsA[0]);
  return retStddev[1];
}
项目:PhET    文件:Sticks.java   
/**
 * 
 * @param x
 * @param y
 * @param bsVisible  UNUSED?
 * @param pt
 * @return picked bond or null
 */
private Bond findPickedBond(int x, int y, BitSet bsVisible, Point3fi pt) {
  int dmin2 = MAX_BOND_CLICK_DISTANCE_SQUARED;
  if (g3d.isAntialiased()) {
    x <<= 1;
    y <<= 1;
    dmin2 <<= 1;
  }
  Bond pickedBond = null;
  Point3f v = new Point3f();
  Bond[] bonds = modelSet.getBonds();
  for (int i = modelSet.getBondCount(); --i >= 0;) {
    Bond bond = bonds[i];
    if (bond.getShapeVisibilityFlags() == 0)
      continue;
    Atom atom1 = bond.getAtom1();
    Atom atom2 = bond.getAtom2();
    if (!atom1.isVisible(0) || !atom2.isVisible(0))
      continue;
    v.set(atom1);
    v.add(atom2);
    v.scale(0.5f);
    int d2 = coordinateInRange(x, y, v, dmin2, ptXY);
    if (d2 >= 0) {
      float f = 1f * (ptXY.x - atom1.screenX) / (atom2.screenX - atom1.screenX);
      if (f < 0.4f || f > 0.6f)
        continue;
      dmin2 = d2;
      pickedBond = bond;
      pt.set(v);
      pt.modelIndex = atom1.modelIndex;
    }
  }
  return pickedBond;
}
项目:PhET    文件:AlphaMonomer.java   
@Override
public Quaternion getQuaternion(char qType) {
  /*
   * also NucleicMonomer, AminoMonomer
   * 
   * This definition is only for alpha-only chains
   *   
   */

  Vector3f vA = new Vector3f();
  Vector3f vB = new Vector3f();
  Vector3f vC = null;

  switch (qType) {
  default:
  case 'a':
  case 'n':
  case 'p':
  case 'q':
    return null;
  case 'b':
  case 'c':
  case 'x':
    //vA = ptCa(i+1) - ptCa
    //vB = ptCa(i-1) - ptCa
    if (monomerIndex == 0 
        || monomerIndex == bioPolymer.monomerCount - 1)
      return null;
    Point3f ptCa = getLeadAtom();
    Point3f ptCaNext = bioPolymer.getLeadPoint(monomerIndex + 1);
    Point3f ptCaPrev = bioPolymer.getLeadPoint(monomerIndex - 1);
    vA.sub(ptCaNext, ptCa);
    vB.sub(ptCaPrev, ptCa);
    break;
  }
  return Quaternion.getQuaternionFrame(vA, vB, vC, false);
}
项目:PhET    文件:Measure.java   
public static List<Point3f> transformPoints(List<Point3f> vPts, Matrix4f m4, Point3f center) {
  List<Point3f> v = new ArrayList<Point3f>();
  for (int i = 0; i < vPts.size(); i++) {
    Point3f pt = new Point3f(vPts.get(i));
    pt.sub(center);
    m4.transform(pt, pt);
    pt.add(center);
    v.add(pt);
  }
  return v;
}
项目:PhET    文件:BioPolymer.java   
public Point3f[] getControlPoints(boolean isTraceAlpha, float sheetSmoothing,
                                  boolean invalidate) {
  if (invalidate)
    invalidControl = true;
  return (!isTraceAlpha ? leadMidpoints : sheetSmoothing == 0 ? leadPoints
      : getControlPoints(sheetSmoothing));
}
项目:PhET    文件:Viewer.java   
public BitSet addHydrogens(BitSet bsAtoms, boolean asScript, boolean isSilent) {
  boolean doAll = (bsAtoms == null);
  if (bsAtoms == null)
    bsAtoms = getModelUndeletedAtomsBitSet(getVisibleFramesBitSet().length() - 1);
  BitSet bsB = new BitSet();
  if (bsAtoms.cardinality() == 0)
    return bsB;
  int modelIndex = modelSet.atoms[bsAtoms.nextSetBit(0)].modelIndex;
  if (modelIndex != modelSet.getModelCount() - 1)
    return bsB;
  List<Atom> vConnections = new ArrayList<Atom>();
  Point3f[] pts = getAdditionalHydrogens(bsAtoms, doAll, false, vConnections);
  boolean wasAppendNew = false;
  wasAppendNew = getAppendNew();
  if (pts.length > 0) {
    clearModelDependentObjects();
    try {
      bsB = (asScript ? modelSet.addHydrogens(vConnections, pts)
          : addHydrogensInline(bsAtoms, vConnections, pts));
    } catch (Exception e) {
      e.printStackTrace();
      // ignore
    }
    if (wasAppendNew)
      setAppendNew(true);
  }
  if (!isSilent)
    scriptStatus(GT._("{0} hydrogens added", pts.length));
  return bsB;
}
项目:Analyst    文件:SymmetryPlane.java   
public void findSublabialeFP(){

        if (labraleInferiusFP == null){
            return;
        }

        Point3f sublabialeCandidate = new Point3f(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);

        // prva moznost, bez predpokladu, ze mnozina bodov symetrickej roviny je usporiadana
        for(Point3f symPoint : symmetryPlanePoints) {
            if (symPoint.y < labraleInferiusFP.getPosition().y && symPoint.y > labraleInferiusFP.getPosition().y - SEARCH_THRESHOLD) {
                if (symPoint.z < sublabialeCandidate.z)
                    sublabialeCandidate = symPoint;
            }
        }

        // druha moznost, s predpokladom usporiadania
//        Point3f previousPoint = symmetryPlanePoints.getFirst(); // sublabialeCandidate
//        for(int i = 1; i < symmetryPlanePoints.size(); i++){
//            Point3f symPoint = symmetryPlanePoints.get(i);
//            if (symPoint.y < labraleInferiusFP.y && symPoint.y < previousPoint.y && symPoint.y > labraleInferiusFP.y - SEARCH_THRESHOLD) {
//                if (symPoint.z > previousPoint.z) {
//                    sublabialeCandidate = previousPoint;
//                    break;
//                }          
//                previousPoint = symPoint;
//            }
//        }

        sublabialeFP = new FacialPoint(FacialPointType.SL, sublabialeCandidate);
        facialPoints.add(sublabialeFP);
    }
项目:PhET    文件:SmarterJmolAdapter.java   
/**
 * 
 * needed to consolidate a set of models into one model; could start
 * with AtomSetCollectionReader[] or with AtomSetCollection[]
 * 
 * @param readerSet 
 * @param atomsets 
 * @param htParams 
 * @return a single AtomSetCollection or an error string
 * 
 */
@SuppressWarnings("unchecked")
@Override
public Object getAtomSetCollectionFromSet(Object readerSet, Object atomsets,
                                          Map<String, Object> htParams) {
  AtomSetCollectionReader[] readers = (AtomSetCollectionReader[]) readerSet;
  AtomSetCollection[] asc = (atomsets == null ? new AtomSetCollection[readers.length]
      : (AtomSetCollection[]) atomsets);
  if (atomsets == null) {
    for (int i = 0; i < readers.length; i++) {
      try {
        Object ret = readers[i].readData();
        if (!(ret instanceof AtomSetCollection))
          return ret;
        asc[i] = (AtomSetCollection) ret;
        if (asc[i].errorMessage != null)
          return asc[i].errorMessage;
      } catch (Throwable e) {
        Logger.error(null, e);
        return "" + e;
      }
    }
  }
  if (htParams.containsKey("trajectorySteps")) {
    // this is one model with a set of coordinates from a 
    // molecular dynamics calculation
    // all the htParams[] entries point to the same Hashtable
    asc[0].finalizeTrajectory((List<Point3f[]>) htParams.get("trajectorySteps"));
    return asc[0];
  }
  AtomSetCollection result = new AtomSetCollection(asc);
  return (result.errorMessage == null ? result : (Object) result.errorMessage);
}
项目:PhET    文件:AlphaPolymer.java   
@Override
protected Point3f getControlPoint(int i, Vector3f v) {
  if (!monomers[i].isSheet())
    return leadPoints[i];
  v.sub(leadMidpoints[i], leadPoints[i]);
  v.scale(sheetSmoothing);
  Point3f pt = new Point3f(leadPoints[i]);
  pt.add(v);
  return pt;
}
项目:PhET    文件:_IdtfExporter.java   
private String getTriangleResource(String key, Point3f pt1,
                                   Point3f pt2, Point3f pt3) {
  Point3f[] vertexes = new Point3f[] { pt1, pt2, pt3 };
  tempV1.set(pt3);
  tempV1.sub(pt1);
  tempV2.set(pt2);
  tempV2.sub(pt1);
  tempV2.cross(tempV2, tempV1);
  tempV2.normalize();
  Vector3f[] normals = new Vector3f[] { tempV2, tempV2, tempV2 };
  return getMeshData(key, triangleFace, vertexes, normals);
}
项目:PhET    文件:ASimpleJvxlWriter.java   
public static String jvxlGetData(VoxelDataCreator vdc, Parameters params,
                                 VolumeData volumeData, String[] title,
                                 List<Point3f> surfacePointsReturn,
                                 float[] areaVolumeReturn) {

  JvxlData jvxlData = new JvxlData();
  new SimpleMarchingCubes(vdc, volumeData, params,
      jvxlData, surfacePointsReturn, areaVolumeReturn);
  jvxlData.isXLowToHigh = params.isXLowToHigh;
  jvxlData.cutoff = params.cutoff;
  jvxlData.isCutoffAbsolute = params.isCutoffAbsolute;
  jvxlData.version = "ASimpleJvxlWriter -- version 2.2";
  return JvxlCoder.jvxlGetFile(volumeData, jvxlData, title);
}
项目:PhET    文件:MdCrdReader.java   
@SuppressWarnings("unchecked")
@Override
protected void initializeReader() {
  // add a dummy atom, just so not "no atoms found"
  atomSetCollection.addAtom(new Atom());
  trajectorySteps = (List<Point3f[]>) htParams.get("trajectorySteps");
  if (trajectorySteps == null) {
    htParams.put("trajectorySteps", trajectorySteps = new ArrayList<Point3f[]>());
  }
}
项目:PhET    文件:ModelCollection.java   
private void calcUnitCellMinMax() {
  for (int i = 0; i < modelCount; i++) {
    if (!unitCells[i].getCoordinatesAreFractional())
      continue;
    Point3f[] vertices = unitCells[i].getUnitCellVertices();
    for (int j = 0; j < 8; j++)
      boxInfo.addBoundBoxPoint(vertices[j]);
  }
}
项目:PhET    文件:SurfaceReader.java   
public int addVertexCopy(Point3f vertexXYZ, float value, int assocVertex) {
  if (Float.isNaN(value) && assocVertex != MarchingSquares.EDGE_POINT)
    return -1;
  if (meshDataServer == null)
    return meshData.addVertexCopy(vertexXYZ, value, assocVertex);
  return meshDataServer.addVertexCopy(vertexXYZ, value, assocVertex);
}
项目:PhET    文件:QuantumCalculation.java   
protected void setupCoordinates(float[] originXYZ, float[] stepsXYZ,
                                BitSet bsSelected, Point3f[] atomCoordAngstroms) {

  // all coordinates come in as angstroms, not bohr, and are converted here into bohr

  for (int i = 3; --i >= 0;) {
    originBohr[i] = originXYZ[i] * unitFactor;
    stepBohr[i] = stepsXYZ[i] * unitFactor;
    volume *= stepBohr[i];
  }
  setXYZBohr(xBohr, 0, nX);
  setXYZBohr(yBohr, 1, nY);
  setXYZBohr(zBohr, 2, nZ);

  /* 
   * allowing null atoms allows for selectively removing
   * atoms from the rendering. Maybe a first time this has ever been done?
   * 
   */

  qmAtoms = new QMAtom[atomCoordAngstroms.length];
  boolean isAll = (bsSelected == null);
  int i0 = (isAll ? qmAtoms.length - 1 : bsSelected.nextSetBit(0));
  for (int i = i0; i >= 0; i = (isAll ? i - 1 : bsSelected.nextSetBit(i + 1)))
    qmAtoms[i] = new QMAtom((Atom) atomCoordAngstroms[i], X, Y, Z, X2, Y2, Z2);
  if (doDebug)
    Logger.debug("QuantumCalculation:\n origin(Bohr)= " + originBohr[0] + " "
        + originBohr[1] + " " + originBohr[2] + "\n steps(Bohr)= "
        + stepBohr[0] + " " + stepBohr[1] + " " + stepBohr[2] + "\n counts= "
        + nX + " " + nY + " " + nZ);
}
项目:PhET    文件:__RayTracerExporter.java   
@Override
void drawCylinder(Point3f screenA, Point3f screenB, short colix1,
                         short colix2, byte endcaps, int madBond,
                         int bondOrder) {
  // from drawBond and fillCylinder here
  if (colix1 == colix2) {
    fillConicalCylinder(screenA, screenB, madBond, colix1, endcaps);
  } else {
    tempV2.set(screenB);
    tempV2.add(screenA);
    tempV2.scale(0.5f);
    tempP1.set(tempV2);
    fillConicalCylinder(screenA, tempP1, madBond, colix1, endcaps);
    fillConicalCylinder(tempP1, screenB, madBond, colix2, endcaps);
  }
  if (endcaps != Graphics3D.ENDCAPS_SPHERICAL)
    return;

  float radius = viewer.scaleToScreen((int) screenA.z, madBond) / 2f;
  if (radius <= 1)
    return;
  outputSphere(screenA.x, screenA.y, screenA.z, radius, colix1);
  radius = viewer.scaleToScreen((int) screenB.z, madBond) / 2f;
  if (radius <= 1)
    return;
  outputSphere(screenB.x, screenB.y, screenB.z, radius, colix2);

}
项目:PhET    文件:EnvelopeCalculation.java   
private AtomIndexIterator getNeighbors(AtomIndexIterator iter) {
  neighborCount = 0;
  if (disregardNeighbors)
    return null;
  viewer.setIteratorForAtom(iter, indexI, radiusI + diameterP + maxRadius);    
  while (iter.hasNext()) {
    int indexN = iter.next();
    float neighborRadius = atomData.atomRadius[indexN];
    if (centerI.distance(atomData.atomXyz[indexN]) > radiusI + radiusP + radiusP
        + neighborRadius)
      continue;
    if (neighborCount == neighborIndices.length) {
      neighborIndices = ArrayUtil.doubleLength(neighborIndices);
      neighborCenters = (Point3f[]) ArrayUtil.doubleLength(neighborCenters);
      neighborPlusProbeRadii2 = ArrayUtil
          .doubleLength(neighborPlusProbeRadii2);
      neighborRadii2 = ArrayUtil.doubleLength(neighborRadii2);
    }
    neighborCenters[neighborCount] = atomData.atomXyz[indexN];
    neighborIndices[neighborCount] = indexN;
    float r = neighborRadius + radiusP;
    neighborPlusProbeRadii2[neighborCount] = r * r;
    neighborRadii2[neighborCount] = neighborRadius * neighborRadius;
    ++neighborCount;
  }
  return iter;
}
项目:PhET    文件:AminoMonomer.java   
Point3f getExplicitNH() {
  Atom nitrogen = getNitrogenAtom();
  Atom h = null;
  Bond[] bonds = nitrogen.getBonds();
  if (bonds == null)
    return null;
  for (int i = 0; i < bonds.length; i++)
    if ((h = bonds[i].getOtherAtom(nitrogen)).getElementNumber() == 1)
      return h;
  return null;
}
项目:PhET    文件:DrawRenderer.java   
private void drawLineData(List<Point3f[]> lineData) {
  if (diameter == 0)
    diameter = 3;
  for (int i = lineData.size(); --i >= 0;) {
    Point3f[] pts = lineData.get(i);
    viewer.transformPoint(pts[0], pt1i);
    viewer.transformPoint(pts[1], pt2i);
    drawLine(-1, -2, true, pts[0], pts[1], pt1i, pt2i);
  }
}
项目:PhET    文件:SymmetryOperation.java   
SymmetryOperation(SymmetryOperation op, Point3f[] atoms,
                         int atomIndex, int count, boolean doNormalize) {
  /*
   * externalizes and transforms an operation for use in atom reader
   * 
   */
  this.doNormalize = doNormalize;
  xyzOriginal = op.xyzOriginal;
  xyz = op.xyz;
  this.opId = op.opId;
  set(op); // sets the underlying Matrix4f
  doFinalize();
  if (doNormalize)
    setOffset(atoms, atomIndex, count);
}
项目:PhET    文件:ModelCollection.java   
public Point3f getAtomSetCenter(BitSet bs) {
  Point3f ptCenter = new Point3f(0, 0, 0);
  int nPoints = 0;
  if (bs != null)
    for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
      if (!isJmolDataFrame(atoms[i])) {
        nPoints++;
        ptCenter.add(atoms[i]);
      }
    }
  if (nPoints > 0)
    ptCenter.scale(1.0f / nPoints);
  return ptCenter;
}
项目:PhET    文件:Measure.java   
public static void calcNormalizedNormal(Point3f pointA, Point3f pointB,
       Point3f pointC, Vector3f vNormNorm, Vector3f vAB, Vector3f vAC) {
  vAB.sub(pointB, pointA);
  vAC.sub(pointC, pointA);
  vNormNorm.cross(vAB, vAC);
  vNormNorm.normalize();
}
项目:PhET    文件:Viewer.java   
void rotateAtoms(Matrix3f mNew, Matrix3f matrixRotate, boolean fullMolecule,
                 Point3f center, boolean isInternal, BitSet bsAtoms) {
  // from TransformManager exclusively
  modelSet.rotateAtoms(mNew, matrixRotate, bsAtoms, fullMolecule, center,
      isInternal);
  refreshMeasures(true);
  checkMinimization();
}
项目:PhET    文件:IsosurfaceMesh.java   
int addVertexCopy(Point3f vertex, float value, int assocVertex, boolean associateNormals) {
  int vPt = addVertexCopy(vertex, value);
  switch (assocVertex) {
  case MarchingSquares.CONTOUR_POINT:
    if (firstRealVertex < 0)
      firstRealVertex = vPt;
    break;
  case MarchingSquares.VERTEX_POINT:
    hasGridPoints = true;
    break;
  case MarchingSquares.EDGE_POINT:
    vertexIncrement = 3;
    break;
  default:
    if (firstRealVertex < 0)
      firstRealVertex = vPt;
    if (associateNormals) {
      if (assocGridPointMap == null) {
        assocGridPointMap = new Hashtable<Integer, Integer>();
        assocGridPointNormals = new Hashtable<Integer, Vector3f>();
      }
      Integer key = Integer.valueOf(assocVertex);
      assocGridPointMap.put(Integer.valueOf(vPt), key);
      if (!assocGridPointNormals.containsKey(key))
        assocGridPointNormals.put(key, new Vector3f(0, 0, 0));
    }
  }
  return vPt;
}