Java Code Examples for javax.vecmath.Point3d#scale()
The following examples show how to use
javax.vecmath.Point3d#scale() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DragBallEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
protected void renderTranslationHandle(GL2 gl2,Vector3d n) { // draw line to box gl2.glBegin(GL2.GL_LINES); gl2.glVertex3d(0,0,0); gl2.glVertex3d(n.x,n.y,n.z); gl2.glEnd(); // draw box Point3d b0 = new Point3d(+0.05,+0.05,+0.05); Point3d b1 = new Point3d(-0.05,-0.05,-0.05); b0.scale(1); b1.scale(1); b0.add(n); b1.add(n); PrimitiveSolids.drawBox(gl2, b0,b1); }
Example 2
Source File: MomentsOfInertia.java From biojava with GNU Lesser General Public License v2.1 | 6 votes |
public Point3d getCenterOfMass() { if (points.size() == 0) { throw new IllegalStateException( "MomentsOfInertia: no points defined"); } Point3d center = new Point3d(); double totalMass = 0.0; for (int i = 0, n = points.size(); i < n; i++) { double mass = masses.get(i); totalMass += mass; center.scaleAdd(mass, points.get(i), center); } center.scale(1.0 / totalMass); return center; }
Example 3
Source File: DragBallEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
protected double testBoxHit(Ray ray,Vector3d n) { Point3d b0 = new Point3d(); Point3d b1 = new Point3d(); b0.set(+0.05,+0.05,+0.05); b1.set(-0.05,-0.05,-0.05); b0.scale(ballSize.get()); b1.scale(ballSize.get()); b0.add(n); b1.add(n); return MathHelper.rayBoxIntersection(ray,b0,b1); }
Example 4
Source File: CalcPoint.java From biojava with GNU Lesser General Public License v2.1 | 5 votes |
/** * Calculate the centroid of the point cloud. * * @param x * array of points. Point objects will not be modified * @return centroid as Point3d */ public static Point3d centroid(Point3d[] x) { Point3d center = new Point3d(); for (Point3d p : x) { center.add(p); } center.scale(1.0 / x.length); return center; }