Documentation ¶
Overview ¶
Package offering various methods for intersection testing between different geometric objects.
Index ¶
- func Det(a, b, c, d float32) float32
- func Det64(a, b, c, d float64) float64
- func DistanceLinePoint(startX, startY, endX, endY, pointX, pointY float32) float32
- func DistanceSegmentPoint(startX, startY, endX, endY, pointX, pointY float32) float32
- func DistanceSegmentPointV2(start, end, point *Vector2) float32
- func IntersectLinePlane(x, y, z, x2, y2, z2 float32, plane *Plane, intersection *Vector3) float32
- func IntersectLinePolygon(p1, p2 *Vector2, polygon *Polygon) bool
- func IntersectLines(x1, y1, x2, y2, x3, y3, x4, y4 float32, intersection *Vector2) bool
- func IntersectLinesV3(p1, p2, p3, p4, intersection *Vector2) bool
- func IntersectRayBounds(ray *Ray, box *BoundingBox, intersection *Vector3) bool
- func IntersectRayBoundsFast(ray *Ray, box *BoundingBox) bool
- func IntersectRayBoundsFastV3(ray *Ray, center, dimensions *Vector3) bool
- func IntersectRayPlane(ray *Ray, plane *Plane, intersection *Vector3) bool
- func IntersectRayRay(start1, direction1, start2, direction2 *Vector2) float32
- func IntersectRaySphere(ray *Ray, center *Vector3, radius float32, intersection *Vector3) bool
- func IntersectRayTriangle(ray *Ray, t1, t2, t3, intersection *Vector3) bool
- func IntersectRayTriangles(ray *Ray, triangles []float32, intersection *Vector3) bool
- func IntersectRayTrianglesIndex(ray *Ray, vertices []float32, indices []uint8, vertexSize uint8, ...) bool
- func IntersectRayTrianglesV3(ray *Ray, triangles []*Vector3, intersection *Vector3) bool
- func IntersectRectangles(rectangle1, rectangle2, intersection *Rectangle) bool
- func IntersectSegmentCircle(start, end, center *Vector2, squareRadius float32) bool
- func IntersectSegmentCircleDisplace(start, end, point *Vector2, radius float32, displacement *Vector2) float32
- func IntersectSegmentPlane(start, end *Vector3, plane *Plane, intersection *Vector3) bool
- func IntersectSegmentPolygon(p1, p2 *Vector2, polygon *Polygon) bool
- func IntersectSegments(x1, y1, x2, y2, x3, y3, x4, y4 float32, intersection *Vector2) bool
- func IntersectSegmentsV2(p1, p2, p3, p4, intersection *Vector2) bool
- func IsPointInPolygonV2(polygon []*Vector2, point *Vector2) bool
- func IsPointInTriangle(px, py, ax, ay, bx, by, cx, cy float32) bool
- func IsPointInTriangleV2(p, a, b, c *Vector2) bool
- func IsPointInTriangleV3(point, t1, t2, t3 *Vector3) bool
- func NearestSegmentPoint(startX, startY, endX, endY, pointX, pointY float32, nearest *Vector2) *Vector2
- func NearestSegmentPointV2(start, end, point, nearest *Vector2) *Vector2
- func OverlapConvexPolygons(verts1 []float32, offset1 int, count1 int, verts2 []float32, offset2 int, ...) bool
- func OverlapConvexPolygonsP(p1, p2 *Polygon, mtv *MinimumTranslationVector) bool
- func OverlapConvexPolygonsV(verts1, verts2 []float32, mtv *MinimumTranslationVector) bool
- func OverlapsC(c1, c2 *Circle) bool
- func OverlapsCR(c *Circle, r *Rectangle) bool
- func OverlapsR(r1, r2 *Rectangle) bool
- func PointLineSide(linePoint1X, linePoint1Y, linePoint2X, linePoint2Y, pointX, pointY float32) int
- func PointLineSideV2(linePoint1, linePoint2, point *Vector2) int
- func SplitEdge(vertices []float32, s, e, stride int, plane *Plane, split []float32, ...)
- func SplitTriangleF(triangle []float32, plane *Plane, split SplitTriangle)
- type MinimumTranslationVector
- type SplitTriangle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DistanceLinePoint ¶
Returns the distance between the given line and point. Note the specified line is not a line segment.
func DistanceSegmentPoint ¶
Returns the distance between the given segment and point.
func DistanceSegmentPointV2 ¶
func DistanceSegmentPointV2(start, end, point *Vector2) float32
Returns the distance between the given segment and point.
func IntersectLinePlane ¶
Intersects a line and a plane. The intersection is returned as the distance from the first point to the plane. In case an intersection happened, the return value is in the range [0,1]. The intersection point can be recovered by point1 + t * (point2 - point1) where t is the return value of this method.
func IntersectLinePolygon ¶
func IntersectLinePolygon(p1, p2 *Vector2, polygon *Polygon) bool
Check whether the given line and {@link Polygon} intersect. param p1 The first point of the line param p2 The second point of the line param polygon The polygon return Whether polygon and line intersects
func IntersectLines ¶
Intersects the two lines and returns the intersection point in intersection. param intersection The intersection point, or null. return Whether the two lines intersect
func IntersectLinesV3 ¶
func IntersectLinesV3(p1, p2, p3, p4, intersection *Vector2) bool
Intersects the two lines and returns the intersection point in intersection. param p1 The first point of the first line param p2 The second point of the first line param p3 The first point of the second line param p4 The second point of the second line param intersection The intersection point return Whether the two lines intersect
func IntersectRayBounds ¶
func IntersectRayBounds(ray *Ray, box *BoundingBox, intersection *Vector3) bool
Intersects a {@link Ray} and a {@link BoundingBox}, returning the intersection point in intersection. This intersection is defined as the point on the ray closest to the origin which is within the specified bounds.
The returned intersection (if any) is guaranteed to be within the bounds of the bounding box, but it can occasionally diverge slightly from ray, due to small floating-point errors.</p>
If the origin of the ray is inside the box, this method returns true and the intersection point is set to the origin of the ray, accordingly to the definition above.</p>
param ray The ray param box The box param intersection The intersection point (optional) return Whether an intersection is present.
func IntersectRayBoundsFast ¶
func IntersectRayBoundsFast(ray *Ray, box *BoundingBox) bool
Quick check whether the given {@link Ray} and {@link BoundingBox} intersect. param ray The ray param box The bounding box return Whether the ray and the bounding box intersect.
func IntersectRayBoundsFastV3 ¶
func IntersectRayBoundsFastV3(ray *Ray, center, dimensions *Vector3) bool
Quick check whether the given {@link Ray} and {@link BoundingBox} intersect. param ray The ray param center The center of the bounding box param dimensions The dimensions (width, height and depth) of the bounding box return Whether the ray and the bounding box intersect.
func IntersectRayPlane ¶
func IntersectRayPlane(ray *Ray, plane *Plane, intersection *Vector3) bool
Intersects a {@link Ray} and a {@link Plane}. The intersection point is stored in intersection in case an intersection is present. param intersection The vector the intersection point is written to (optional) return Whether an intersection is present.
func IntersectRayRay ¶
func IntersectRayRay(start1, direction1, start2, direction2 *Vector2) float32
Intersect two 2D Rays and return the scalar parameter of the first ray at the intersection point. You can get the intersection point by: Vector2 point(direction1).scl(scalar).add(start1); For more information, check: http://stackoverflow.com/a/565282/1091440 param start1 Where the first ray start param direction1 The direction the first ray is pointing param start2 Where the second ray start param direction2 The direction the second ray is pointing return scalar parameter on the first ray describing the point where the intersection happens. May be negative. In case the rays are collinear, math will be returned.
func IntersectRaySphere ¶
Intersects a {@link Ray} and a sphere, returning the intersection point in intersection. param ray The ray, the direction component must be normalized before calling this method param center The center of the sphere param radius The radius of the sphere param intersection The intersection point (optional, can be null) return Whether an intersection is present.
func IntersectRayTriangle ¶
func IntersectRayTriangle(ray *Ray, t1, t2, t3, intersection *Vector3) bool
Intersect a {@link Ray} and a triangle, returning the intersection point in intersection. param ray The ray param t1 The first vertex of the triangle param t2 The second vertex of the triangle param t3 The third vertex of the triangle param intersection The intersection point (optional) return True in case an intersection is present.
func IntersectRayTriangles ¶
Intersects the given ray with list of triangles. Returns the nearest intersection point in intersection param ray The ray param triangles The triangles, each successive 3 elements from a vertex param intersection The nearest intersection point (optional) return Whether the ray and the triangles intersect.
func IntersectRayTrianglesIndex ¶
func IntersectRayTrianglesIndex(ray *Ray, vertices []float32, indices []uint8, vertexSize uint8, intersection *Vector3) bool
Intersects the given ray with list of triangles. Returns the nearest intersection point in intersection param ray The ray param vertices the vertices param indices the indices, each successive 3 shorts index the 3 vertices of a triangle param vertexSize the size of a vertex in floats param intersection The nearest intersection point (optional) return Whether the ray and the triangles intersect.
func IntersectRayTrianglesV3 ¶
func IntersectRayTrianglesV3(ray *Ray, triangles []*Vector3, intersection *Vector3) bool
Intersects the given ray with list of triangles. Returns the nearest intersection point in intersection param ray The ray param triangles The triangles param intersection The nearest intersection point (optional) return Whether the ray and the triangles intersect.
func IntersectRectangles ¶
func IntersectRectangles(rectangle1, rectangle2, intersection *Rectangle) bool
Determines whether the given rectangles intersect and, if they do, sets the supplied {@code intersection} rectangle to the area of overlap. return Whether the rectangles intersect
func IntersectSegmentCircle ¶
Returns whether the given line segment intersects the given circle. param start The start point of the line segment param end The end point of the line segment param center The center of the circle param squareRadius The squared radius of the circle return Whether the line segment and the circle intersect
func IntersectSegmentCircleDisplace ¶
func IntersectSegmentCircleDisplace(start, end, point *Vector2, radius float32, displacement *Vector2) float32
Checks whether the line segment and the circle intersect and returns by how much and in what direction the line has to move away from the circle to not intersect.
param start The line segment starting point param end The line segment end point param point The center of the circle param radius The radius of the circle param displacement The displacement vector set by the method having unit length return The displacement or math.MaxFloat32 if no intersection is present
func IntersectSegmentPlane ¶
func IntersectSegmentPlane(start, end *Vector3, plane *Plane, intersection *Vector3) bool
func IntersectSegmentPolygon ¶
func IntersectSegmentPolygon(p1, p2 *Vector2, polygon *Polygon) bool
Check whether the given line segment and {@link Polygon} intersect. param p1 The first point of the segment param p2 The second point of the segment return Whether polygon and segment intersect
func IntersectSegments ¶
func IntersectSegmentsV2 ¶
func IntersectSegmentsV2(p1, p2, p3, p4, intersection *Vector2) bool
Intersects the two line segments and returns the intersection point in intersection. param p1 The first point of the first line segment param p2 The second point of the first line segment param p3 The first point of the second line segment param p4 The second point of the second line segment param intersection The intersection point (optional) return Whether the two line segments intersect
func IsPointInPolygonV2 ¶
func IsPointInPolygonV2(polygon []*Vector2, point *Vector2) bool
Checks whether the given point is in the polygon. param polygon The polygon vertices passed as an array param point The point return true if the point is in the polygon
func IsPointInTriangle ¶
Returns true if the given point is inside the triangle.
func IsPointInTriangleV2 ¶
func IsPointInTriangleV2(p, a, b, c *Vector2) bool
Returns true if the given point is inside the triangle.
func IsPointInTriangleV3 ¶
func IsPointInTriangleV3(point, t1, t2, t3 *Vector3) bool
Returns whether the given point is inside the triangle. This assumes that the point is on the plane of the triangle. No check is performed that this is the case.
param point the point param t1 the first vertex of the triangle param t2 the second vertex of the triangle param t3 the third vertex of the triangle return whether the point is in the triangle
func NearestSegmentPoint ¶
func NearestSegmentPoint(startX, startY, endX, endY, pointX, pointY float32, nearest *Vector2) *Vector2
Returns a point on the segment nearest to the specified point.
func NearestSegmentPointV2 ¶
func NearestSegmentPointV2(start, end, point, nearest *Vector2) *Vector2
Returns a point on the segment nearest to the specified point.
func OverlapConvexPolygons ¶
func OverlapConvexPolygons(verts1 []float32, offset1 int, count1 int, verts2 []float32, offset2 int, count2 int, mtv *MinimumTranslationVector) bool
Check whether polygons defined by the given counter-clockwise wound vertex arrays overlap. If they do, optionally obtain a Minimum Translation Vector indicating the minimum magnitude vector required to push the polygon defined by verts1 out of the collision with the polygon defined by verts2. param verts1 Vertices of the first polygon. param verts2 Vertices of the second polygon. param mtv A Minimum Translation Vector to fill in the case of a collision, or null (optional). return Whether polygons overlap.
func OverlapConvexPolygonsP ¶
func OverlapConvexPolygonsP(p1, p2 *Polygon, mtv *MinimumTranslationVector) bool
Check whether specified counter-clockwise wound convex polygons overlap. If they do, optionally obtain a Minimum Translation Vector indicating the minimum magnitude vector required to push the polygon p1 out of collision with polygon p2. param p1 The first polygon. param p2 The second polygon. param mtv A Minimum Translation Vector to fill in the case of a collision, or null (optional). return Whether polygons overlap.
func OverlapConvexPolygonsV ¶
func OverlapConvexPolygonsV(verts1, verts2 []float32, mtv *MinimumTranslationVector) bool
@see #overlapConvexPolygons(float[], int, int, float[], int, int, MinimumTranslationVector)
func OverlapsCR ¶
func OverlapsCR(c *Circle, r *Rectangle) bool
func PointLineSide ¶
func PointLineSideV2 ¶
func PointLineSideV2(linePoint1, linePoint2, point *Vector2) int
Determines on which side of the given line the point is. Returns -1 if the point is on the left side of the line, 0 if the point is on the line and 1 if the point is on the right side of the line. Left and right are relative to the lines direction which is linePoint1 to linePoint2.
func SplitTriangleF ¶
func SplitTriangleF(triangle []float32, plane *Plane, split SplitTriangle)
Splits the triangle by the plane. The result is stored in the SplitTriangle instance. Depending on where the triangle is relative to the plane, the result can be: <li>Triangle is fully in front/behind: {@link SplitTriangle#front} or {@link SplitTriangle#back} will contain the original triangle, {@link SplitTriangle#total} will be one.</li> <li>Triangle has two vertices in front, one behind: {@link SplitTriangle#front} contains 2 triangles, {@link SplitTriangle#back} contains 1 triangles, {@link SplitTriangle#total} will be 3.</li> <li>Triangle has one vertex in front, two behind: {@link SplitTriangle#front} contains 1 triangle, {@link SplitTriangle#back} contains 2 triangles, {@link SplitTriangle#total} will be 3.</li> The input triangle should have the form: x, y, z, x2, y2, z2, x3, y3, z3. One can add additional attributes per vertex which will be interpolated if split, such as texture coordinates or normals. Note that these additional attributes won't be normalized, as might be necessary in case of normals. param triangle param plane param split output SplitTriangle
Types ¶
type MinimumTranslationVector ¶
type MinimumTranslationVector struct {
// contains filtered or unexported fields
}
type SplitTriangle ¶
type SplitTriangle struct { FrontCurrent bool // contains filtered or unexported fields }
func NewSplitTriangle ¶
func NewSplitTriangle(numAttributes int) *SplitTriangle
Creates a new instance, assuming numAttributes attributes per triangle vertex. param numAttributes must be >= 3
func (*SplitTriangle) Add ¶
func (self *SplitTriangle) Add(vertex []float32, offset, stride int)
func (*SplitTriangle) Reset ¶
func (self *SplitTriangle) Reset()