org.vectomatic.common.model.geometry
Class Segment

java.lang.Object
  extended by org.vectomatic.common.model.geometry.Segment
All Implemented Interfaces:
com.google.gwt.user.client.rpc.IsSerializable
Direct Known Subclasses:
BezierSegment, LineSegment

public abstract class Segment
extends Object
implements com.google.gwt.user.client.rpc.IsSerializable

Base class for path segments (line segment, bezier spline segments)

Author:
Lukas Laag

Field Summary
protected  BoundingBox _bbox
           
protected  Point[] _pts
           
 
Constructor Summary
Segment()
           
Segment(Point[] pts)
          Constructor
Segment(Segment segment)
          Copy constuctor
 
Method Summary
abstract  Segment clone()
           
 BoundingBox getBoundingBox()
          Gets the bounding box of the segment
 Point getEndPoint()
          Return the segment last point
 Point getStartPoint()
          Returns the segment first point
 Point[] getVertices()
           
abstract  void nearestPointOnSegment(Point p, Point dest)
          Returns the closest point on the segment to the specified point
 float squaredDistanceToPoint(Point p)
          Returns the squared distance from an arbitrary point p to the nearest point on the segment
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_pts

protected Point[] _pts

_bbox

protected BoundingBox _bbox
Constructor Detail

Segment

public Segment()

Segment

public Segment(Point[] pts)
Constructor

Parameters:
pts - An array of points defining the segment

Segment

public Segment(Segment segment)
Copy constuctor

Parameters:
segment - A segment to duplicate
Method Detail

getStartPoint

public Point getStartPoint()
Returns the segment first point

Returns:

getEndPoint

public Point getEndPoint()
Return the segment last point

Returns:

getBoundingBox

public BoundingBox getBoundingBox()
Gets the bounding box of the segment

Returns:
the bounding box of the segment

squaredDistanceToPoint

public float squaredDistanceToPoint(Point p)
Returns the squared distance from an arbitrary point p to the nearest point on the segment

Parameters:
p - An arbitrary point p
Returns:
The squared distance from the closest point on the segment to p

nearestPointOnSegment

public abstract void nearestPointOnSegment(Point p,
                                           Point dest)
Returns the closest point on the segment to the specified point

Parameters:
p - An arbitrary point p
dest - The closest point on the segment to p

clone

public abstract Segment clone()
Overrides:
clone in class Object

getVertices

public Point[] getVertices()


Copyright © 2010. All Rights Reserved.