/** * Constructs a segment with the specified endpoints. * @param a the endpoint A. * @param b the endpoint B. */ public Segment(Point3 a, Point3 b) { _a = new Point3(a); _b = new Point3(b); _d = _b.minus(_a); }
public void testPoint() { int ntrial = 10; for (int itrial=0; itrial<ntrial; ++itrial) { Point3 p = randomPoint3(); Point3 pc = new Point3(p); Vector3 v = randomVector3(); assertEquals(p,p.plus(v).minus(v)); assertEquals(p,pc.plusEquals(v).minusEquals(v)); Point3 q = p.minus(v); assertEquals(q.distanceTo(p),v.length()); } }
/** * Transforms this segment, given the specified transform matrix. * @param m the transform matrix. */ public void transform(Matrix44 m) { _a = m.times(_a); _b = m.times(_b); _d = _b.minus(_a); }
private void duringTranslate(MouseEvent e) { int x = e.getX(); int y = e.getY(); Point3 p = new Point3(x,y,_zmouse); Vector3 t = _translate.plus(_translateM.times(p).minus(_translateP)); _view.setTranslate(t); }
/** * Constructs a mouse constrained by a plane. The constraint plane contains * the specified origin point and is parallel to the specified plane. The * origin point is typically near, but not necessarily on, the specified * plane. * @param event the initial mouse event. * @param origin the origin point, in local coordinates. * @param plane the plane, in local coordinates. * @param localToPixel the transform from local to pixel coordinates. */ public MouseOnPlane( MouseEvent event, Point3 origin, Plane plane, Matrix44 localToPixel) { super(localToPixel); //_origin = new Point3(origin); _normal = plane.getNormal(); _plane = new Plane(plane); _delta = origin.minus(getPointOnPlane(event)); }
public void drag(DragContext dc) { assert _mouseConstrained!=null:"mouseConstrained!=null"; Point3 point = _mouseConstrained.getPoint(dc.getMouseEvent()); //BoxConstraint constraint = _frame.getBoxConstraint(); //if (constraint!=null && !constraint.containsPoint(point)) // return; Vector3 vector = point.minus(_origin); Point3 qa = _qa.plus(vector); Point3 qb = _qb.plus(vector); _frame.setCorners(qa,qb); updateHandles(); } public void dragEnd(DragContext dc) {
Point3 a = segment.getA(); Point3 b = segment.getB(); Vector3 d = b.minus(a);
translate.plusEquals(m.times(c2).minus(m.times(c1))); view.setTranslate(translate);