com.threerings.tudey.shape
Class Segment

java.lang.Object
  extended by com.threerings.tudey.shape.Shape
      extended by com.threerings.tudey.shape.Segment

public class Segment
extends Shape

A line segment.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.tudey.shape.Shape
Shape.IntersectionType
 
Constructor Summary
Segment()
          Creates an uninitialized segment.
Segment(Vector2f start, Vector2f end)
          Creates a segment between the specified points.
 
Method Summary
 ShapeConfig createConfig()
          Creates a config corresponding to this shape.
 void draw(boolean outline)
          Draws this shape in immediate mode.
 Shape expand(float amount, Shape result)
          Expands this shape, placing the result in the provided object if possible.
 Vector2f getCenter(Vector2f result)
          Retrieves the center of the shape and places it in the supplied vector.
 Vector2f getEnd()
          Returns a reference to the end vertex.
 boolean getIntersection(Ray2D ray, Vector2f result)
          Finds the intersection of a ray with this shape and places it in the supplied vector (if it exists).
 Shape.IntersectionType getIntersectionType(Rect rect)
          Checks whether the intersector intersects the specified rect.
 void getNearestPoint(Vector2f point, Vector2f result)
          Fins the nearest point of this element to the supplied point and places it in the supplied vector.
 Vector2f getPenetration(Capsule capsule, Vector2f result)
          Finds the penetration of the specified capsule into this shape.
 Vector2f getPenetration(Circle circle, Vector2f result)
          Finds the penetration of the specified circle into this shape.
 Vector2f getPenetration(Compound compound, Vector2f result)
          Finds the penetration of the specified compound into this shape.
 Vector2f getPenetration(Point point, Vector2f result)
          Finds the penetration of the specified point into this shape.
 Vector2f getPenetration(Polygon polygon, Vector2f result)
          Finds the penetration of the specified polygon into this shape.
 Vector2f getPenetration(Segment segment, Vector2f result)
          Finds the penetration of the specified segment into this shape.
 Vector2f getPenetration(Shape shape, Vector2f result)
          Finds the penetration of the specified shape into this one, assuming that they intersect.
 Vector2f[] getPerimeterPath()
          Returns a perimeter path for this shape.
 Vector2f getStart()
          Returns a reference to the start vertex.
 boolean intersects(Capsule capsule)
          Checks for an intersection with this shape and the specified capsule.
 boolean intersects(Circle circle)
          Checks for an intersection with this shape and the specified circle.
 boolean intersects(Compound compound)
          Checks for an intersection with this shape and the specified compound.
 boolean intersects(Point point)
          Checks for an intersection with this shape and the specified point.
 boolean intersects(Polygon polygon)
          Checks for an intersection with this shape and the specified polygon.
 boolean intersects(Segment segment)
          Checks for an intersection with this shape and the specified segment.
 boolean intersects(Shape shape)
          Determines whether this shape intersects the specified shape.
 boolean intersects(SpaceElement element)
          Determines whether this shape intersects the specified element.
 boolean intersects(Vector2f pt)
          Determines whether this segment intersects the specified point.
 boolean intersects(Vector2f ostart, Vector2f oend)
          Determines whether this segment intersects the segment with the provided start and end points.
 Shape sweep(Vector2f translation, Shape result)
          Computes the shape created by sweeping this shape along the specified translation vector, placing the result in the provided object if possible.
 String toString()
           
 Shape transform(Transform2D transform, Shape result)
          Transforms this shape, placing the result in the provided object if possible.
 void updateBounds()
          Updates the bounds of the shape.
 
Methods inherited from class com.threerings.tudey.shape.Shape
expand, expandLocal, getBounds, getCenter, getPenetration, intersects, sweep, transform, transformLocal
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Segment

public Segment(Vector2f start,
               Vector2f end)
Creates a segment between the specified points.


Segment

public Segment()
Creates an uninitialized segment.

Method Detail

getStart

public Vector2f getStart()
Returns a reference to the start vertex.


getEnd

public Vector2f getEnd()
Returns a reference to the end vertex.


intersects

public boolean intersects(Vector2f pt)
Determines whether this segment intersects the specified point.


intersects

public boolean intersects(Vector2f ostart,
                          Vector2f oend)
Determines whether this segment intersects the segment with the provided start and end points.


updateBounds

public void updateBounds()
Description copied from class: Shape
Updates the bounds of the shape.

Specified by:
updateBounds in class Shape

getCenter

public Vector2f getCenter(Vector2f result)
Description copied from class: Shape
Retrieves the center of the shape and places it in the supplied vector.

Specified by:
getCenter in class Shape
Returns:
a reference to the result vector, for chaining.

transform

public Shape transform(Transform2D transform,
                       Shape result)
Description copied from class: Shape
Transforms this shape, placing the result in the provided object if possible.

Specified by:
transform in class Shape
Returns:
a reference to the result object, if it was reused; otherwise, a new object containing the result.

expand

public Shape expand(float amount,
                    Shape result)
Description copied from class: Shape
Expands this shape, placing the result in the provided object if possible.

Specified by:
expand in class Shape
Returns:
a reference to the result object, if it was reused; otherwise, a new object containing the result.

sweep

public Shape sweep(Vector2f translation,
                   Shape result)
Description copied from class: Shape
Computes the shape created by sweeping this shape along the specified translation vector, placing the result in the provided object if possible.

Specified by:
sweep in class Shape
Returns:
a reference to the result object, if it was reused; otherwise, a new object containing the result.

getPerimeterPath

public Vector2f[] getPerimeterPath()
Description copied from class: Shape
Returns a perimeter path for this shape.

Overrides:
getPerimeterPath in class Shape

getIntersection

public boolean getIntersection(Ray2D ray,
                               Vector2f result)
Description copied from class: Shape
Finds the intersection of a ray with this shape and places it in the supplied vector (if it exists).

Specified by:
getIntersection in class Shape
Returns:
true if the ray intersected the shape (in which case the result will contain the point of intersection), false otherwise.

getNearestPoint

public void getNearestPoint(Vector2f point,
                            Vector2f result)
Description copied from class: Shape
Fins the nearest point of this element to the supplied point and places it in the supplied vector.

Specified by:
getNearestPoint in class Shape

getIntersectionType

public Shape.IntersectionType getIntersectionType(Rect rect)
Description copied from class: Shape
Checks whether the intersector intersects the specified rect.

Specified by:
getIntersectionType in class Shape

intersects

public boolean intersects(SpaceElement element)
Description copied from class: Shape
Determines whether this shape intersects the specified element. Uses double-dispatch to invoke the appropriate specialization of SpaceElement.intersects(com.threerings.tudey.shape.Point).

Specified by:
intersects in class Shape

intersects

public boolean intersects(Shape shape)
Description copied from class: Shape
Determines whether this shape intersects the specified shape. Uses double-dispatch to invoke the appropriate method specialization.

Specified by:
intersects in class Shape

intersects

public boolean intersects(Point point)
Description copied from class: Shape
Checks for an intersection with this shape and the specified point.

Specified by:
intersects in class Shape

intersects

public boolean intersects(Segment segment)
Description copied from class: Shape
Checks for an intersection with this shape and the specified segment.

Specified by:
intersects in class Shape

intersects

public boolean intersects(Circle circle)
Description copied from class: Shape
Checks for an intersection with this shape and the specified circle.

Specified by:
intersects in class Shape

intersects

public boolean intersects(Capsule capsule)
Description copied from class: Shape
Checks for an intersection with this shape and the specified capsule.

Specified by:
intersects in class Shape

intersects

public boolean intersects(Polygon polygon)
Description copied from class: Shape
Checks for an intersection with this shape and the specified polygon.

Specified by:
intersects in class Shape

intersects

public boolean intersects(Compound compound)
Description copied from class: Shape
Checks for an intersection with this shape and the specified compound.

Specified by:
intersects in class Shape

getPenetration

public Vector2f getPenetration(Shape shape,
                               Vector2f result)
Description copied from class: Shape
Finds the penetration of the specified shape into this one, assuming that they intersect. The penetration vector represents the minimum translation required to separate the two shapes. Uses double-dispatch to invoke the appropriate method specialization.

Specified by:
getPenetration in class Shape
Returns:
a reference to the result vector, for chaining.

getPenetration

public Vector2f getPenetration(Point point,
                               Vector2f result)
Description copied from class: Shape
Finds the penetration of the specified point into this shape.

Specified by:
getPenetration in class Shape

getPenetration

public Vector2f getPenetration(Segment segment,
                               Vector2f result)
Description copied from class: Shape
Finds the penetration of the specified segment into this shape.

Specified by:
getPenetration in class Shape

getPenetration

public Vector2f getPenetration(Circle circle,
                               Vector2f result)
Description copied from class: Shape
Finds the penetration of the specified circle into this shape.

Specified by:
getPenetration in class Shape

getPenetration

public Vector2f getPenetration(Capsule capsule,
                               Vector2f result)
Description copied from class: Shape
Finds the penetration of the specified capsule into this shape.

Specified by:
getPenetration in class Shape

getPenetration

public Vector2f getPenetration(Polygon polygon,
                               Vector2f result)
Description copied from class: Shape
Finds the penetration of the specified polygon into this shape.

Specified by:
getPenetration in class Shape

getPenetration

public Vector2f getPenetration(Compound compound,
                               Vector2f result)
Description copied from class: Shape
Finds the penetration of the specified compound into this shape.

Specified by:
getPenetration in class Shape

draw

public void draw(boolean outline)
Description copied from class: Shape
Draws this shape in immediate mode.

Specified by:
draw in class Shape
Parameters:
outline - if true, draw the outline of the shape; otherwise, the solid form.

createConfig

public ShapeConfig createConfig()
Description copied from class: Shape
Creates a config corresponding to this shape.

Specified by:
createConfig in class Shape

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.