/** * Returns the length of this segment. * @return the length. */ public double length() { return _a.distanceTo(_b); }
public void mouseDragged(MouseEvent e) { // See if mouse has moved too much for selecting. _selecting = _dragContext==null; if (_selecting && _pickResult!=null) { Point3 pp = _pickResult.getPointPixel(); Point3 pd = new Point3(e.getX(),e.getY(),pp.z); if (pp.distanceTo(pd)>=2.0) _selecting = false; } // If (1) not selecting, and (2) the picked node is dragable, and // (3) we are not yet dragging, then initiate dragging. if (!_selecting && _dragable!=null && _dragContext==null) { _dragContext = new DragContext(_pickResult); _dragable.dragBegin(_dragContext); } // If we are now dragging, update the drag context and drag. if (_dragable!=null && _dragContext!=null) { _dragContext.update(e); _dragable.drag(_dragContext); } } };
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()); } }