/** * Gets the current point in world coordinates. * @return the current point in world coordinates. */ public Point3 getPointWorld() { return new Point3(_pointWorld); }
/** * Returns the length of this segment. * @return the length. */ public double length() { return _a.distanceTo(_b); }
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()); } }
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) {
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); } } };
/** * Gets the constrained point in local coordinates for the specified event. * The constrained point lies in the constraint plane that contains the * origin point. * @param event the mouse event. * @return the constrained point, in local coordinates. */ public Point3 getPoint(MouseEvent event) { return getPointOnPlane(event).plusEquals(_delta); }
/** * 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); }
@Override public String toString() { return (this.getLocation().toString()+" "+_text); }
Vector3 v1 = segment.getB().minus(p1); Vector3 a = p2.minus(p1); Vector3 b = v1; Vector3 c = v1.cross(v2); double cc = c.lengthSquared(); double t = a.cross(b).dot(c)/cc; point = p2.plus(v2.times(t)); double ymouse = event.getY(); double scale = 0.05*(_ymouse-ymouse)/height; point = _origin.plus(_vector.times(scale*_length));
/** * Gets the point in local coordinates for the specified event. * @param event the mouse event. * @return the point, in local coordinates. */ public Point3 getPoint(MouseEvent event) { return getPointOnLine(event).plusEquals(_delta); }
/** * 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)); }
/** * Gets the current point in pixel coordinates. * @return the current point in pixel coordinates. */ public Point3 getPointPixel() { return new Point3(_pointPixel); }
/** * Gets the picked point in world coordinates. * @return the picked point in world coordinates. */ public Point3 getPointWorld() { return new Point3(_pointWorld); }
double r = bs.getRadius(); Point3 c = bs.getCenter(); Point3 x = new Point3(c.x+r,c.y,c.z); Point3 y = new Point3(c.x,c.y+r,c.z); Point3 z = new Point3(c.x,c.y,c.z+r); c = _transform.times(c); x = _transform.times(x); y = _transform.times(y); z = _transform.times(z); Vector3 cx = c.minus(x); Vector3 cy = c.minus(y); Vector3 cz = c.minus(z); double lx = cx.length(); double ly = cy.length();
/** * Gets the endpoint A of this segment. * @return the endpoint A. */ public Point3 getA() { return new Point3(_a); }
/** * Returns the point q = p-v, for this point p and the specified vector v. * @param v the vector v. * @return the point q = p-v. */ public Point3 minus(Vector3 v) { return new Point3(x-v.x,y-v.y,z-v.z); }