package geo

Import Path
	oss.terrastruct.com/d2/lib/geo (on go.dev)

Dependency Relation
	imports 7 packages, and imported by 15 packages


Package-Level Type Names (total 12)
/* sort by: | */
Curve *bezier.Curve ( BezierCurve) At(point float64) *Point ( BezierCurve) Intersections(segment Segment) []*Point BezierCurve : Intersectable func NewBezierCurve(points []*Point) *BezierCurve
Height float64 TopLeft *Point Width float64 (*Box) Center() *Point (*Box) Contains(p *Point) bool (*Box) Copy() *Box (*Box) Intersections(s Segment) []*Point Intersects returns true if the segment comes within buffer of the box ( Box) Overlaps(b2 Box) bool (*Box) ToString() string *Box : Intersectable func NewBox(tl *Point, width, height float64) *Box func (*Box).Copy() *Box func oss.terrastruct.com/d2/lib/shape.Shape.GetBox() *Box func oss.terrastruct.com/d2/lib/shape.Shape.GetInnerBox() *Box func oss.terrastruct.com/d2/lib/shape.Shape.GetInnerBoxForContent(width, height float64) *Box func Box.Overlaps(b2 Box) bool func oss.terrastruct.com/d2/lib/label.Position.GetPointOnBox(box *Box, padding, width, height float64) *Point func oss.terrastruct.com/d2/lib/shape.NewCallout(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewCircle(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewClass(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewCloud(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewCode(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewCylinder(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewDiamond(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewDocument(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewHexagon(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewImage(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewOval(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewPackage(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewPage(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewParallelogram(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewPerson(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewQueue(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewRealSquare(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewShape(shapeType string, box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewSquare(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewStep(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewStoredData(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewTable(box *Box) shape.Shape func oss.terrastruct.com/d2/lib/shape.NewText(box *Box) shape.Shape func oss.terrastruct.com/d2/d2target.GetIconSize(box *Box, position string) int
Center *Point Rx float64 Ry float64 ( Ellipse) Intersections(segment Segment) []*Point Ellipse : Intersectable func NewEllipse(center *Point, rx, ry float64) *Ellipse
( Intersectable) Intersections(segment Segment) []*Point BezierCurve *Box Ellipse Segment oss.terrastruct.com/d2/d2graph.Object func oss.terrastruct.com/d2/lib/shape.Shape.Perimeter() []Intersectable
( Orientation) GetOpposite() Orientation ( Orientation) IsDiagonal() bool ( Orientation) IsHorizontal() bool ( Orientation) IsVertical() bool ( Orientation) SameSide(o2 Orientation) bool ( Orientation) ToString() string func Orientation.GetOpposite() Orientation func (*Point).GetOrientation(pTo *Point) Orientation func Orientation.SameSide(o2 Orientation) bool const Bottom const BottomLeft const BottomRight const Left const NONE const Right const Top const TopLeft const TopRight
X float64 Y float64 Moves the given point by Vector (*Point) Compare(p2 *Point) int (*Point) Copy() *Point https://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment (*Point) Equals(p2 *Point) bool (*Point) FormattedCoordinates() string GetOrientation gets orientation of pFrom to pTo E.g. pFrom ---> pTo, here, pFrom is to the left of pTo, so Left would be returned point t% of the way between a and b returns true if point p is on orthogonal segment between points a and b (*Point) ToString() string Creates a Vector pointing to point (*Point) Transpose() (*Point) TruncateDecimals() (*Point) TruncateFloat32() Creates a Vector of the size between start and endpoint, pointing to endpoint func ComputeIntersections(px, py, lx, ly []float64) []*Point func IntersectionPoint(u0, u1, v0, v1 *Point) *Point func NewPoint(x, y float64) *Point func BezierCurve.At(point float64) *Point func BezierCurve.Intersections(segment Segment) []*Point func (*Box).Center() *Point func (*Box).Intersections(s Segment) []*Point func Ellipse.Intersections(segment Segment) []*Point func Intersectable.Intersections(segment Segment) []*Point func (*Point).AddVector(v Vector) *Point func (*Point).Copy() *Point func (*Point).Interpolate(b *Point, t float64) *Point func Points.GetMedian() *Point func Route.GetBoundingBox() (tl, br *Point) func Route.GetPointAtDistance(distance float64) (*Point, int) func Segment.Intersections(otherSegment Segment) []*Point func Vector.ToPoint() *Point func oss.terrastruct.com/d2/lib/label.Position.GetPointOnBox(box *Box, padding, width, height float64) *Point func oss.terrastruct.com/d2/lib/label.Position.GetPointOnRoute(route Route, strokeWidth, labelPercentage, width, height float64) (point *Point, index int) func oss.terrastruct.com/d2/lib/shape.TraceToShapeBorder(shape shape.Shape, rectBorderPoint, prevPoint *Point) *Point func oss.terrastruct.com/d2/lib/shape.Shape.GetInsidePlacement(width, height, paddingX, paddingY float64) Point func oss.terrastruct.com/d2/lib/svg.BezierCurveSegment(p1, p2, p3, p4 *Point, t0, t1 float64) (Point, Point, Point, Point) func oss.terrastruct.com/d2/lib/svg.BezierCurveSegment(p1, p2, p3, p4 *Point, t0, t1 float64) (Point, Point, Point, Point) func oss.terrastruct.com/d2/lib/svg.BezierCurveSegment(p1, p2, p3, p4 *Point, t0, t1 float64) (Point, Point, Point, Point) func oss.terrastruct.com/d2/lib/svg.BezierCurveSegment(p1, p2, p3, p4 *Point, t0, t1 float64) (Point, Point, Point, Point) func oss.terrastruct.com/d2/lib/svg.(*SvgPathContext).Absolute(x, y float64) *Point func oss.terrastruct.com/d2/lib/svg.(*SvgPathContext).Relative(base *Point, dx, dy float64) *Point func oss.terrastruct.com/d2/d2graph.(*Object).GetIconTopLeft() *Point func oss.terrastruct.com/d2/d2graph.(*Object).GetLabelTopLeft() *Point func oss.terrastruct.com/d2/d2target.(*Connection).GetArrowheadLabelPosition(isDst bool) *Point func oss.terrastruct.com/d2/d2target.(*Connection).GetLabelTopLeft() *Point func IntersectionPoint(u0, u1, v0, v1 *Point) *Point func NewBezierCurve(points []*Point) *BezierCurve func NewBox(tl *Point, width, height float64) *Box func NewEllipse(center *Point, rx, ry float64) *Ellipse func NewSegment(from, to *Point) *Segment func (*Box).Contains(p *Point) bool func (*Point).Compare(p2 *Point) int func (*Point).DistanceToLine(p1, p2 *Point) float64 func (*Point).Equals(p2 *Point) bool func (*Point).GetOrientation(pTo *Point) Orientation func (*Point).Interpolate(b *Point, t float64) *Point func (*Point).OnOrthogonalSegment(a, b *Point) bool func (*Point).VectorTo(endpoint *Point) Vector func oss.terrastruct.com/d2/lib/shape.TraceToShapeBorder(shape shape.Shape, rectBorderPoint, prevPoint *Point) *Point func oss.terrastruct.com/d2/lib/svg.BezierCurveSegment(p1, p2, p3, p4 *Point, t0, t1 float64) (Point, Point, Point, Point) func oss.terrastruct.com/d2/lib/svg.NewSVGPathContext(tl *Point, sx, sy float64) *svg.SvgPathContext func oss.terrastruct.com/d2/lib/svg.(*SvgPathContext).Relative(base *Point, dx, dy float64) *Point func oss.terrastruct.com/d2/lib/svg.(*SvgPathContext).StartAt(p *Point) func oss.terrastruct.com/d2/d2graph.(*Edge).TraceToShape(points []*Point, startIndex, endIndex int) (newStart, newEnd int) func oss.terrastruct.com/d2/d2renderers/d2sketch.Arrowheads(r jsrunner.JSRunner, connection d2target.Connection, srcAdj, dstAdj *Point) (string, error)
( Points) Equals(other Points) bool ( Points) GetMedian() *Point ( Points) ToString() string func RemovePoints(points Points, toRemove []bool) Points func RemovePoints(points Points, toRemove []bool) Points func Points.Equals(other Points) bool
XPercentage float64 YPercentage float64 func NewRelativePoint(xPercentage, yPercentage float64) *RelativePoint
( Route) GetBoundingBox() (tl, br *Point) return the point at _distance_ along the route, and the index of the segment it's on ( Route) Length() float64 func oss.terrastruct.com/d2/lib/label.Position.GetPointOnRoute(route Route, strokeWidth, labelPercentage, width, height float64) (point *Point, index int)
End *Point Start *Point getBounds takes a segment and returns the floor and ceil of where it can shift to If there is no floor or ceiling, negative or positive infinity is used, respectively The direction is inferred, e.g. b/c the passed in segment is vertical, it's inferred we want horizontal bounds buffer says how close the segment can be, on both axes, to other segments given . │ │ . │ │ . │ │ . │ │ . │ non-overlap . │ . │ . │ . │ segment . │ │ . │ │ ceil . │ │ │ . │ │ . floor │ │ . │ . │ . │ . │ NOTE: the assumption is that all segments given are orthogonal ( Segment) Intersections(otherSegment Segment) []*Point ( Segment) Intersects(otherSegment Segment) bool ( Segment) Length() float64 ( Segment) Overlaps(otherS Segment, isHorizontal bool, buffer float64) bool ( Segment) ToString() string ( Segment) ToVector() Vector Segment : Intersectable func NewSegment(from, to *Point) *Segment func BezierCurve.Intersections(segment Segment) []*Point func (*Box).Intersections(s Segment) []*Point func (*Box).Intersects(s Segment, buffer float64) bool func Ellipse.Intersections(segment Segment) []*Point func Intersectable.Intersections(segment Segment) []*Point func (*Segment).GetBounds(segments []*Segment, buffer float64) (float64, float64) func Segment.Intersections(otherSegment Segment) []*Point func Segment.Intersects(otherSegment Segment) bool func Segment.Overlaps(otherS Segment, isHorizontal bool, buffer float64) bool
Bottom float64 Left float64 Right float64 Top float64 func oss.terrastruct.com/d2/d2graph.(*Object).GetMargin() Spacing func oss.terrastruct.com/d2/d2graph.(*Object).Spacing() (margin, padding Spacing) func oss.terrastruct.com/d2/d2graph.(*Object).SpacingOpt(labelPadding, iconPadding float64, maxIconSize bool) (margin, padding Spacing) func oss.terrastruct.com/d2/d2layouts.FitToGraph(container *d2graph.Object, nestedGraph *d2graph.Graph, padding Spacing)
A N-Dimensional Vector with components (x, y, z, ...) based on the origin ( Vector) Add(b Vector) Vector Creates a Vector by extending the length of the current one by length ( Vector) Degrees() float64 ( Vector) Length() float64 ( Vector) Minus(b Vector) Vector ( Vector) Multiply(v float64) Vector ( Vector) Radians() float64 ( Vector) Reverse() Vector ( Vector) ToPoint() *Point Creates an unit Vector pointing in the same direction of this Vector func NewVector(components ...float64) Vector func NewVectorFromProperties(length float64, angleInRadians float64) Vector func (*Point).ToVector() Vector func (*Point).VectorTo(endpoint *Point) Vector func Segment.ToVector() Vector func Vector.Add(b Vector) Vector func Vector.AddLength(length float64) Vector func Vector.Minus(b Vector) Vector func Vector.Multiply(v float64) Vector func Vector.Reverse() Vector func Vector.Unit() Vector func (*Point).AddVector(v Vector) *Point func Vector.Add(b Vector) Vector func Vector.Minus(b Vector) Vector var oss.terrastruct.com/d2/d2target.BorderOffset
Package-Level Functions (total 16)
nolint
func EuclideanDistance(x1, y1, x2, y2 float64) float64
func GetUnitNormalVector(x1, y1, x2, y2 float64) (float64, float64)
get the point of intersection between line segments u and v (or nil if they do not intersect)
func NewBezierCurve(points []*Point) *BezierCurve
func NewBox(tl *Point, width, height float64) *Box
func NewEllipse(center *Point, rx, ry float64) *Ellipse
func NewPoint(x, y float64) *Point
func NewRelativePoint(xPercentage, yPercentage float64) *RelativePoint
func NewSegment(from, to *Point) *Segment
New Vector from components
New Vector of length and pointing in the direction of angle
compare a and b and consider them equal if difference is less than precision e (e.g. e=0.001)
RemovePoints returns a new Points slice without the points in toRemove
func Sign(i float64) int
TruncateDecimals truncates floats to keep up to 3 digits after decimal, to avoid issues with floats on different machines. Since we're not launching rockets, 3 decimals is enough precision for what we're doing
Package-Level Constants (total 10)
const Bottom Orientation = 6
const Left Orientation = 7
const NONE Orientation = 8
How precise should comparisons be, avoid being too precise due to floating point issues
const Right Orientation = 5
const Top Orientation = 4
const TopLeft Orientation = 0