Interface Shape2D<ST extends Shape2D<?,?,I,P,V,B>,IT extends Shape2D<?,?,I,P,V,B>,I extends PathIterator2D<?>,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Shape2D<?,?,I,P,V,B>>
-
- Type Parameters:
ST
- is the type of the general implementation.IT
- is the type of the implementation of this shape.I
- is the type of the iterator used to obtain the elements of the path.P
- is the type of the points.V
- is the type of the vectors.B
- is the type of the bounding boxes.
- All Superinterfaces:
Cloneable
,JsonableObject
,Serializable
- All Known Subinterfaces:
Circle2afp<ST,IT,IE,P,V,B>
,Circle2ai<ST,IT,IE,P,V,B>
,Ellipse2afp<ST,IT,IE,P,V,B>
,MultiShape2afp<ST,IT,CT,IE,P,V,B>
,MultiShape2ai<ST,IT,CT,IE,P,V,B>
,MultiShape2D<ST,IT,CT,I,P,V,B>
,OrientedRectangle2afp<ST,IT,IE,P,V,B>
,Parallelogram2afp<ST,IT,IE,P,V,B>
,Path2afp<ST,IT,IE,P,V,B>
,Path2ai<ST,IT,IE,P,V,B>
,Path2D<ST,IT,I,P,V,B>
,Rectangle2afp<ST,IT,IE,P,V,B>
,Rectangle2ai<ST,IT,IE,P,V,B>
,RectangularShape2afp<ST,IT,IE,P,V,B>
,RectangularShape2ai<ST,IT,IE,P,V,B>
,RoundRectangle2afp<ST,IT,IE,P,V,B>
,Segment2afp<ST,IT,IE,P,V,B>
,Segment2ai<ST,IT,IE,P,V,B>
,Shape2afp<ST,IT,IE,P,V,B>
,Shape2ai<ST,IT,IE,P,V,B>
,Shape2d<IT>
,Shape2dfx<IT>
,Shape2i<IT>
,Shape2ifx<IT>
,Triangle2afp<ST,IT,IE,P,V,B>
- All Known Implementing Classes:
AbstractRectangularShape2d
,AbstractRectangularShape2dfx
,AbstractRectangularShape2i
,AbstractRectangularShape2ifx
,AbstractShape2d
,AbstractShape2dfx
,AbstractShape2i
,AbstractShape2ifx
,Circle2d
,Circle2dfx
,Circle2i
,Circle2ifx
,Ellipse2d
,Ellipse2dfx
,MultiShape2d
,MultiShape2dfx
,MultiShape2i
,MultiShape2ifx
,OrientedRectangle2d
,OrientedRectangle2dfx
,Parallelogram2d
,Parallelogram2dfx
,Path2d
,Path2dfx
,Path2i
,Path2ifx
,Rectangle2d
,Rectangle2dfx
,Rectangle2i
,Rectangle2ifx
,RoundRectangle2d
,RoundRectangle2dfx
,Segment2d
,Segment2dfx
,Segment2i
,Segment2ifx
,SegmentPoint2d
,SegmentPoint2i
,Triangle2d
,Triangle2dfx
public interface Shape2D<ST extends Shape2D<?,?,I,P,V,B>,IT extends Shape2D<?,?,I,P,V,B>,I extends PathIterator2D<?>,P extends Point2D<? super P,? super V>,V extends Vector2D<? super V,? super P>,B extends Shape2D<?,?,I,P,V,B>> extends Cloneable, Serializable, JsonableObject
2D shape.- Since:
- 13.0
- Version:
- 17.0 2020-01-04 14:41:43
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- mathgeom
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
clear()
Reset this shape to be equivalent to an just-created instance of this shape type.IT
clone()
Clone this shape.boolean
contains(Point2D<?,?> point)
Replies if the given point is inside this shape.boolean
contains(Shape2D<?,?,?,?,?,?> shape)
Replies if this shape is inside the given shape.ST
createTransformedShape(Transform2D transform)
Apply the transformation to the shape and reply the result.static <IT extends Shape2D<?,?,?,?,?,?>>
booleanequals(Shape2D<?,IT,?,?,?,?> obj1, Object obj2)
Do a safe equality test between the two shapes.default boolean
equalsToPathIterator(PathIterator2D<?> pathIterator)
Replies this shape as the same path iterator as the given one.boolean
equalsToShape(IT shape)
Replies this shape is equal to the given shape.P
getClosestPointTo(Point2D<?,?> point)
Replies the point on the shape that is closest to the given point.P
getClosestPointTo(Shape2D<?,?,?,?,?,?> shape)
Replies the point on the shape that is closest to the given shape.default double
getDistance(Point2D<?,?> point)
Replies the minimal distance from this shape to the given point.default double
getDistance(Shape2D<?,?,?,?,?,?> shape)
Replies the minimal distance from this shape to the given shape.double
getDistanceL1(Point2D<?,?> point)
Computes the L-1 (Manhattan) distance between this shape and point p1.double
getDistanceLinf(Point2D<?,?> point)
Computes the L-infinite distance between this shape and point p1.double
getDistanceSquared(Point2D<?,?> point)
Replies the squared value of the minimal distance from this shape to the given point.double
getDistanceSquared(Shape2D<?,?,?,?,?,?> shape)
Replies the squared value of the minimal distance from this shape to the given shape.P
getFarthestPointTo(Point2D<?,?> point)
Replies the point on the shape that is farthest the given point.GeomFactory2D<V,P>
getGeomFactory()
Replies the geometry factory associated to this point.default I
getPathIterator()
Replies an iterator on the path elements.I
getPathIterator(Transform2D transform)
Replies the elements of the paths.boolean
intersects(Shape2D<?,?,?,?,?,?> shape)
Replies if this shape is intersecting the given shape.boolean
isEmpty()
Replies if this shape is empty.default void
operator_add(Vector2D<?,?> v)
Translate this shape by adding the given vector:this += v
default boolean
operator_and(Point2D<?,?> point)
Replies if the given point is inside the shape:this && b
default boolean
operator_and(Shape2D<?,?,?,?,?,?> shape)
Replies if the given shape has an intersection with this shape:this && b
default IT
operator_minus(Vector2D<?,?> v)
Create a new shape by translating this shape of the given vector:this - v
default ST
operator_multiply(Transform2D t)
Create a new shape by applying the given transformation:this * t
default IT
operator_plus(Vector2D<?,?> v)
Create a new shape by translating this shape of the given vector:this + v
default void
operator_remove(Vector2D<?,?> v)
Translate this shape by substracting the given vector:this -= v
default double
operator_upTo(Point2D<?,?> pt)
Replies the distance between the given point and this shape:this .. p
void
set(IT shape)
Set this shape with the attributes of the given shape.B
toBoundingBox()
Replies the bounding box of this shape.void
toBoundingBox(B box)
Replies the bounds of the shape.void
translate(Vector2D<?,?> vector)
Translate the shape.-
Methods inherited from interface org.arakhne.afc.vmutil.json.JsonableObject
toJson
-
-
-
-
Method Detail
-
getGeomFactory
@Pure GeomFactory2D<V,P> getGeomFactory()
Replies the geometry factory associated to this point.- Returns:
- the factory.
-
isEmpty
@Pure boolean isEmpty()
Replies if this shape is empty. The semantic associated to the state "empty" depends on the implemented shape. See the subclasses for details.- Returns:
true
if the shape is empty;false
otherwise.
-
clone
@Pure IT clone()
Clone this shape.- Returns:
- the clone.
-
equals
@Pure static <IT extends Shape2D<?,?,?,?,?,?>> boolean equals(Shape2D<?,IT,?,?,?,?> obj1, Object obj2)
Do a safe equality test between the two shapes.This function should be used for implementing the
Object.equals(Object)
functions of the shapes.- Type Parameters:
IT
- type of the shapes to compare.- Parameters:
obj1
- the first object to compare.obj2
- the second object to compare.- Returns:
true
if the two shapes are equal.- Since:
- 13.0
-
equalsToPathIterator
@Pure default boolean equalsToPathIterator(PathIterator2D<?> pathIterator)
Replies this shape as the same path iterator as the given one.The equality test does not flatten the paths. It means that is function has is functionnality equivalent to:
PathIterator2D it = this.getPathIterator(); while (it.hasNext() && pathIterator.hasNext()) { PathElement2D e1 = it.next(); PathElement2D e2 = it.next(); if (!e1.equals(e2)) return false; } return !it.hasNext() && !pathIterator.hasNext();
- Parameters:
pathIterator
- the path iterator to compare to the one of this shape.- Returns:
true
if the path iterator of this shape replies the same elements as the given path iterator.
-
equalsToShape
@Pure boolean equalsToShape(IT shape)
Replies this shape is equal to the given shape.- Parameters:
shape
- the shape to compare to.- Returns:
true
if this shape is equal is equal to the given path.
-
clear
void clear()
Reset this shape to be equivalent to an just-created instance of this shape type.
-
contains
@Pure boolean contains(Point2D<?,?> point)
Replies if the given point is inside this shape.- Parameters:
point
- the point.- Returns:
true
if the given shape is intersecting this shape, otherwisefalse
.
-
contains
@Pure boolean contains(Shape2D<?,?,?,?,?,?> shape)
Replies if this shape is inside the given shape.You must use the containing functions with a specific parameter type in place of this general function. Indeed, the implementation of this function is unefficient due to the tests against the types of the given shape, and the cast operators.
- Parameters:
shape
- the shape to compare to.- Returns:
true
if the given shape is inside this shape;false
otherwise.
-
getClosestPointTo
@Pure P getClosestPointTo(Point2D<?,?> point)
Replies the point on the shape that is closest to the given point.- Parameters:
point
- the point.- Returns:
- the closest point on the shape; or the point itself if it is inside the shape.
-
getClosestPointTo
@Pure P getClosestPointTo(Shape2D<?,?,?,?,?,?> shape)
Replies the point on the shape that is closest to the given shape.If the two shapes are intersecting, the replied point is always at the intersection of the two shapes. This function does not enforce the meaning of the replied point in the case of shape intersection. In other words, this function is warranting that the reply point is the either the penetration point, nor a perimeter point, nor any point with a specific meaning.
- Parameters:
shape
- the shape.- Returns:
- the closest point on the shape.
-
getFarthestPointTo
@Pure P getFarthestPointTo(Point2D<?,?> point)
Replies the point on the shape that is farthest the given point.- Parameters:
point
- the point.- Returns:
- the farthest point on the shape.
-
getDistance
@Pure default double getDistance(Point2D<?,?> point)
Replies the minimal distance from this shape to the given point.- Parameters:
point
- the point.- Returns:
- the minimal distance between this shape and the point.
-
getDistance
@Pure default double getDistance(Shape2D<?,?,?,?,?,?> shape)
Replies the minimal distance from this shape to the given shape.- Parameters:
shape
- the shape.- Returns:
- the minimal distance between this shape and the given shape.
-
getDistanceSquared
@Pure double getDistanceSquared(Point2D<?,?> point)
Replies the squared value of the minimal distance from this shape to the given point.- Parameters:
point
- the point.- Returns:
- squared value of the minimal distance between this shape and the point.
-
getDistanceSquared
@Pure double getDistanceSquared(Shape2D<?,?,?,?,?,?> shape)
Replies the squared value of the minimal distance from this shape to the given shape.- Parameters:
shape
- the shape.- Returns:
- squared value of the minimal distance between this shape and the given shape.
-
getDistanceL1
@Pure double getDistanceL1(Point2D<?,?> point)
Computes the L-1 (Manhattan) distance between this shape and point p1. The L-1 distance is equal to abs(x1-x2) + abs(y1-y2).- Parameters:
point
- the point- Returns:
- the distance.
-
getDistanceLinf
@Pure double getDistanceLinf(Point2D<?,?> point)
Computes the L-infinite distance between this shape and point p1. The L-infinite distance is equal to MAX[abs(x1-x2), abs(y1-y2)].- Parameters:
point
- the point- Returns:
- the distance.
-
set
void set(IT shape)
Set this shape with the attributes of the given shape.- Parameters:
shape
- the shape to copy.
-
getPathIterator
@Pure default I getPathIterator()
Replies an iterator on the path elements.The iterator for this class is not multi-threaded safe.
- Returns:
- an iterator on the path elements.
-
getPathIterator
@Pure I getPathIterator(Transform2D transform)
Replies the elements of the paths.- Parameters:
transform
- is the transformation to apply to the path.- Returns:
- the elements of the path.
-
createTransformedShape
@Pure ST createTransformedShape(Transform2D transform)
Apply the transformation to the shape and reply the result. This function does not change the current shape.- Parameters:
transform
- is the transformation to apply to the shape.- Returns:
- the result of the transformation.
-
translate
void translate(Vector2D<?,?> vector)
Translate the shape.- Parameters:
vector
- the translation vector.
-
toBoundingBox
@Pure B toBoundingBox()
Replies the bounding box of this shape.- Returns:
- the bounding box of this shape.
-
toBoundingBox
void toBoundingBox(B box)
Replies the bounds of the shape.- Parameters:
box
- is set with the bounds of the shape.
-
intersects
@Pure boolean intersects(Shape2D<?,?,?,?,?,?> shape)
Replies if this shape is intersecting the given shape.You must use the intersection functions with a specific parameter type in place of this general function. Indeed, the implementation of this function is unefficient due to the tests against the types of the given shape, and the cast operators.
- Parameters:
shape
- the shape to compare to.- Returns:
true
if this shape is intersecting the given shape;false
if there is no intersection.
-
operator_add
default void operator_add(Vector2D<?,?> v)
Translate this shape by adding the given vector:this += v
This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
v
- the vector- See Also:
translate(Vector2D)
-
operator_plus
@Pure default IT operator_plus(Vector2D<?,?> v)
Create a new shape by translating this shape of the given vector:this + v
This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
v
- the vector- Returns:
- the transformed shape.
- See Also:
translate(Vector2D)
-
operator_remove
default void operator_remove(Vector2D<?,?> v)
Translate this shape by substracting the given vector:this -= v
This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
v
- the vector- See Also:
translate(Vector2D)
-
operator_minus
@Pure default IT operator_minus(Vector2D<?,?> v)
Create a new shape by translating this shape of the given vector:this - v
This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
v
- the vector- Returns:
- the transformed shape.
- See Also:
translate(Vector2D)
-
operator_multiply
@Pure default ST operator_multiply(Transform2D t)
Create a new shape by applying the given transformation:this * t
This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
t
- the transformation- Returns:
- the transformed shape.
- See Also:
createTransformedShape(Transform2D)
-
operator_and
@Pure default boolean operator_and(Point2D<?,?> point)
Replies if the given point is inside the shape:this && b
This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
point
- the point to test.- Returns:
true
if the point is inside the shape. Otherwise,false
.- See Also:
createTransformedShape(Transform2D)
-
operator_and
@Pure default boolean operator_and(Shape2D<?,?,?,?,?,?> shape)
Replies if the given shape has an intersection with this shape:this && b
You must use the intersection functions with a specific parameter type in place of this general function. Indeed, the implementation of this function is unefficient due to the tests against the types of the given shape, and the cast operators.
This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
shape
- the shape to test.- Returns:
true
if the shapes are intersecting. Otherwise,false
.- See Also:
intersects(Shape2D)
-
operator_upTo
@Pure default double operator_upTo(Point2D<?,?> pt)
Replies the distance between the given point and this shape:this .. p
This function is an implementation of the operator for the languages that defined or based on the Xtext framework.
- Parameters:
pt
- the point to test.- Returns:
- the distance.
- See Also:
getDistance(Point2D)
-
-