{"id":21419370,"url":"https://github.com/konstantin8105/gog","last_synced_at":"2026-02-17T16:02:29.863Z","repository":{"id":50357207,"uuid":"246579878","full_name":"Konstantin8105/gog","owner":"Konstantin8105","description":"geometry library on golang","archived":false,"fork":false,"pushed_at":"2025-03-18T07:27:12.000Z","size":707,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-14T07:04:48.853Z","etag":null,"topics":["geometry","golang","line","point","segment"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Konstantin8105.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-03-11T13:33:41.000Z","updated_at":"2025-03-18T07:27:15.000Z","dependencies_parsed_at":"2025-02-23T08:22:31.593Z","dependency_job_id":"f1a6208f-8e43-45b8-a116-759853703a21","html_url":"https://github.com/Konstantin8105/gog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Konstantin8105/gog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konstantin8105%2Fgog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konstantin8105%2Fgog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konstantin8105%2Fgog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konstantin8105%2Fgog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Konstantin8105","download_url":"https://codeload.github.com/Konstantin8105/gog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konstantin8105%2Fgog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29549221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T14:33:00.708Z","status":"ssl_error","status_checked_at":"2026-02-17T14:32:58.657Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geometry","golang","line","point","segment"],"created_at":"2024-11-22T19:40:44.404Z","updated_at":"2026-02-17T16:02:29.846Z","avatar_url":"https://github.com/Konstantin8105.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gog\ngolang geometry library between point and segments\n```\n\npackage gog // import \"github.com/Konstantin8105/gog\"\n\n\nCONSTANTS\n\nconst (\n\tCollinearPoints        OrientationPoints = -1\n\tClockwisePoints                          = 0\n\tCounterClockwisePoints                   = 1\n)\nconst (\n\t// Boundary edge\n\tBoundary = -1\n\n\t// Removed element\n\tRemoved = -2\n\n\t// Undefined state only for not valid algorithm\n\tUndefined = -3\n\tFixed     = 100\n\tMovable   = 200\n)\nconst Eps3D = 1e-5\n    Eps3D is default epsilon for 3D operations\n\n\nVARIABLES\n\nvar (\n\t// ErrorDivZero is typical result with not acceptable solving\n\tErrorDivZero = fmt.Errorf(\"div value is too small\")\n\n\t// ErrorNotValidSystem is typical return only if system of\n\t// linear equation have not valid data\n\tErrorNotValidSystem = fmt.Errorf(\"not valid system\")\n)\nvar (\n\t// Debug only for debugging\n\tDebug = false\n\t// Log only for minimal logging\n\tLog = false\n)\nvar (\n\t// Eps is epsilon - precision of intersection\n\tEps = 1e-10\n)\n\nFUNCTIONS\n\nfunc AngleBetween(center, from, mid, to, a Point) (res bool)\n    AngleBetween return true for angle case from \u003c= a \u003c= to\n\nfunc Arc(Arc0, Arc1, Arc2 Point) (xc, yc, r float64)\n    Arc return parameters of circle\n\nfunc ArcSplitByPoint(Arc0, Arc1, Arc2 Point, pi ...Point) (res [][3]Point, err error)\n    ArcSplitByPoint return points of arcs with middle point if pi is empty or\n    slice of arcs.\n\n        DO NOT CHECKED POINT ON ARC\n\nfunc Area(\n\ttr0, tr1, tr2 Point,\n) float64\n    Area return area of triangle\n\nfunc BorderIntersection(ps1, ps2 []Point3d) (intersect bool)\n    BorderIntersection return true only if Borders are intersect\n\nfunc Check(pps ...Point) error\n    Check - check input data\n\nfunc Distance(p0, p1 Point) float64\n    Distance between two points\n\nfunc Distance128(p0, p1 Point) float64\n    Distance128 is distance between 2 points with 128-bit precisions\n\nfunc Distance3d(p0, p1 Point3d) float64\n    Distance3d is distance between 2 points in 3D\n\nfunc IsParallelLine3d(\n\ta0, a1 Point3d,\n\tb0, b1 Point3d,\n) (\n\tparallel bool,\n)\n    IsParallelLines3d return true, if lines are parallel\n\nfunc Line(p0, p1 Point) (A, B, C float64)\n    Line parameters by formula: Ax+By+C = 0\n\nfunc LineArc(Line0, Line1 Point, Arc0, Arc1, Arc2 Point) (\n\tpi []Point,\n\tstA, stB State,\n)\n    LineArc return state and intersections points between line and arc\n\nfunc LineLine(\n\tpa0, pa1 Point,\n\tpb0, pb1 Point,\n) (\n\tpi []Point,\n\tstA, stB State,\n)\n    LineLine return analisys of two segments\n\n    Design of segments:\n\n                                                    //\n        \u003c-- rb00 -- pb0*==========*pb1 -- rb11 --\u003e  // Segment B\n                                                    //\n        \u003c-- ra00 -- pa0*==========*pa1 -- ra11 --\u003e  // Segment A\n        {   ray   }{      segment     }{   ray   }  //\n                                                    //\n\n    Input data:\n\n        ipa0, ipa1 - point indexes of segment A\n        ipb0, ipb1 - point indexes of segment B\n        pps      - pointer of point slice\n\n    Output data:\n\n        pi - intersection point\n        st - states of analisys\n\n    Reference:\n\n        [1]  https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection\n\nfunc LineLine3d(\n\ta0, a1 Point3d,\n\tb0, b1 Point3d,\n) (\n\tratioA, ratioB float64,\n\tintersect bool,\n)\n    LineLine3d return intersection of two points. Point on line corner ignored\n\nfunc Linear(\n\ta11, a12, b1 float64,\n\ta21, a22, b2 float64,\n) (x, y float64, err error)\n    Linear equations solving:\n\n        a11*x + a12*y = b1\n        a21*x + a22*y = b2\n\nfunc Plane(\n\tp1, p2, p3 Point3d,\n) (\n\tA, B, C, D float64,\n)\n    Plane equation `A*x+B*y+C*z+D=0`\n\nfunc PlaneAverage(\n\tps []Point3d,\n) (\n\tA, B, C, D float64,\n)\n    PlaneAverage return parameters of average plane for points\n\nfunc PointArc(pt Point, Arc0, Arc1, Arc2 Point) (\n\tpi []Point,\n\tstA, stB State,\n)\n    PointArc return state and intersections points between point and arc\n\nfunc PointInCircle(point Point, circle [3]Point) bool\n    PointInCircle return true only if point inside circle based on 3 circles\n    points\n\nfunc PointLine(\n\tpt Point,\n\tpb0, pb1 Point,\n) (\n\tpi []Point,\n\tstA, stB State,\n)\n    PointLine return states between point and line.\n\nfunc PointLine3d(\n\tp Point3d,\n\tl0, l1 Point3d,\n) (\n\tintersect bool,\n)\n    PointLine3d return true only if point located on line segment\n\nfunc PointLineDistance(\n\tpc Point,\n\tp0, p1 Point,\n) (distance float64)\n    PointLineDistance return distance between line and point.\n\n    Equation of line:\n\n        (y2-y1)*(x-x1) = (x2-x1)(y-y1)\n        dy*(x-x1) = dx*(y-y1)\n        dy*x-dy*x1-dx*y+dx*y1 = 0\n        Ax+By+C = 0\n        A = dy\n        B = -dx\n        C = -dy*x1+dx*y1\n\n    Distance from point (xm,ym) to line:\n\n        d = |(A*xm+B*ym+C)/sqrt(A^2+B^2)|\n\nfunc PointOnPlane3d(\n\tA, B, C, D float64,\n\tp Point3d,\n) (\n\ton bool,\n)\n    PointOnPlane3d return true if all points on plane\n\nfunc PointPoint(\n\tpt0, pt1 Point,\n) (\n\tpi []Point,\n\tstA, stB State,\n)\n    PointPoint return states between two points.\n\nfunc PointPoint3d(\n\tp0 Point3d,\n\tp1 Point3d,\n) (\n\tintersect bool,\n)\n    PointPoint3d return true only if points have same coordinate\n\nfunc PointTriangle3d(\n\tp Point3d,\n\tt0, t1, t2 Point3d,\n) (\n\tintersect bool,\n)\n    PointTriangle3d return true only if point located inside triangle but do not\n    check point on triangle edge\n\nfunc SamePoints(p0, p1 Point) bool\n    SamePoints return true only if point on very distance or with same\n    coordinates\n\nfunc SamePoints3d(p0, p1 Point3d) bool\n    SamePoints3d return true only if point on very distance or with same\n    coordinates\n\nfunc TriangleSplitByPoint(\n\tpt Point,\n\ttr0, tr1, tr2 Point,\n) (\n\tres [][3]Point,\n\tlineIntersect int,\n\terr error,\n)\n    TriangleSplitByPoint split triangle on triangles only if point inside\n    triangle or on triangle edge\n\nfunc ZeroLine3d(\n\tl0, l1 Point3d,\n) (\n\tzero bool,\n)\n    ZeroLine3d return true only if lenght of line segment is zero\n\nfunc ZeroTriangle3d(\n\tt0, t1, t2 Point3d,\n) (\n\tzero bool,\n)\n    ZeroTriangle3d return true only if triangle have zero area\n\n\nTYPES\n\ntype Mesh struct {\n\tPoints    []int    // tags for points\n\tTriangles [][3]int // indexes of near triangles\n\n\t// Has unexported fields.\n}\n    Mesh is based structure of triangulation. Triangle is data structure\n    \"Nodes, ribs и triangles\" created by book \"Algoritm building and analyse\n    triangulation\", A.B.Skvorcov\n\n        Scketch:\n        +------------------------------------+\n        |              tr[0]                 |\n        |  nodes[0]    ribs[0]      nodes[1] |\n        | o------------------------o         |\n        |  \\                      /          |\n        |   \\                    /           |\n        |    \\                  /            |\n        |     \\                /             |\n        |      \\              /              |\n        |       \\            /  ribs[1]      |\n        |        \\          /   tr[1]        |\n        |  ribs[2]\\        /                 |\n        |  tr[2]   \\      /                  |\n        |           \\    /                   |\n        |            \\  /                    |\n        |             \\/                     |\n        |              o  nodes[2]           |\n        +------------------------------------+\n\nfunc New(model Model) (mesh *Mesh, err error)\n    New triangulation created by model\n\nfunc (mesh *Mesh) AddLine(inp1, inp2 Point) (err error)\n    AddLine is add line in triangulation with tag\n\nfunc (mesh *Mesh) AddPoint(p Point, tag int, triIndexes ...int) (idp int, err error)\n    AddPoint is add points with tag\n\nfunc (mesh Mesh) Check() (err error)\n    Check triangulation on point, line, triangle rules\n\nfunc (mesh *Mesh) Clockwise()\n    Clockwise change all triangles to clockwise orientation\n\nfunc (mesh *Mesh) Delanay(triIndexes ...int) (err error)\n    TODO delanay only for some triangles, if list empty then for all triangles\n\nfunc (mesh *Mesh) GetMaterials(ps ...Point) (materials []int, err error)\n    GetMaterials return materials for each point\n\nfunc (mesh *Mesh) Materials() (err error)\n    Materials indentify all triangles splitted by lines, only if points sliceis\n    empty. If points slice is not empty, then return material mark number for\n    each point\n\nfunc (mesh *Mesh) RemoveMaterials(ps ...Point) (err error)\n    RemoveMaterials remove material by specific points\n\nfunc (mesh *Mesh) SetMaterial(p Point, material int) (err error)\n    SetMaterial change material for point\n\nfunc (mesh *Mesh) Smooth(pts ...int) (err error)\n    Smooth move all movable point by average distance\n\nfunc (mesh *Mesh) Split(factor float64) (err error)\n    Split all triangles edge on distance `factor`\n\nfunc (mesh *Mesh) SplitFunc(factorFunc func(p1, p2 Point) bool) (err error)\n    SplitFunc split all triangles edge on distance only if function argument\n    return true. Example of factorFunc:\n\n        factorFunc = func(p1, p2 Point) bool {\n        \td := gog.Distance(p1, p2)\n        \treturn factor \u003c d\n        }\n\n    If factorFunc is not valid, then splitting will be infinite.\n\ntype Model struct {\n\tPoints    []Point  // Points is slice of points\n\tLines     [][3]int // Lines store 2 index of Points and last for tag\n\tArcs      [][4]int // Arcs store 3 index of Points and last for tag\n\tTriangles [][4]int // Triangles store 3 index of Points and last for tag/material\n\tQuadrs    [][5]int // Rectanges store 4 index of Points and last for tag/material\n}\n    Model of points, lines, arcs for prepare of triangulation\n\nfunc (m *Model) AddArc(start, middle, end Point, tag int)\n    AddArc add arc into model with specific tag\n\nfunc (m *Model) AddCircle(xc, yc, r float64, tag int)\n    AddCircle add arcs based on circle geometry into model with specific tag\n\nfunc (m *Model) AddLine(start, end Point, tag int)\n    AddLine add line into model with specific tag\n\nfunc (m *Model) AddModel(from Model)\n    AddModel inject model into model\n\nfunc (m *Model) AddMultiline(tag int, ps ...Point)\n    AddMultiline add many lines with specific tag\n\nfunc (m *Model) AddPoint(p Point) (index int)\n    AddPoint return index in model slice point\n\nfunc (m *Model) AddTriangle(start, middle, end Point, tag int)\n    AddTriangle add triangle into model with specific tag/material\n\nfunc (m *Model) ArcsToLines()\n    ArcsToLines convert arc to lines\n\nfunc (m *Model) Combine(factorOneLine float64) (err error)\n    Combine triangles to quadr with same tag\n\n        factorOneLine from 1 to 2/sqrt(2) = 1.41\n\n    Recommendation value is 1.05\n\nfunc (m *Model) ConvexHullTriangles()\n    ConvexHullTriangles add triangles of model convex hull\n\nfunc (src Model) Copy() (dst Model)\n    Copy return copy of Model\n\nfunc (m Model) Dxf() string\n    Dxf return string in dxf drawing format\n    https://images.autodesk.com/adsk/files/autocad_2012_pdf_dxf-reference_enu.pdf\n\nfunc (model *Model) Get(mesh *Mesh)\n    Get add into Model all triangles from Mesh Recommendation after `Get` :\n    model.Intersection()\n\nfunc (m *Model) Intersection()\n    Intersection change model with finding all model intersections\n\nfunc (m Model) JSON() (_ string, err error)\n    JSON convert model in JSON format\n\nfunc (to *Model) Merge(from Model)\n    Merge `from` model to `to` model\n\nfunc (m Model) MinPointDistance() (distance float64)\n    MinPointDistance return minimal between 2 points\n\nfunc (m Model) Mirror(p1, p2 Point) (mir Model, err error)\n    Mirror return mirror of model\n\nfunc (m *Model) Move(dx, dy float64)\n    Move all points of model\n\nfunc (m *Model) Read(filename string) (err error)\n    Read model from file with filename in JSON format\n\nfunc (m *Model) RemoveEmptyPoints()\n    RemoveEmptyPoints removed point not connected to line, arcs, triangles\n\nfunc (m *Model) RemovePoint(remove func(p Point) bool)\n    RemovePoint removed point in accoding to function `filter`\n\nfunc (m *Model) Rotate(xc, yc, angle float64)\n    Rotate all points of model around point {xc,yc}\n\nfunc (m *Model) Split(d float64)\n    Split all model lines, arcs by distance `d`\n\nfunc (m Model) String() string\n    String return a stantard model view\n\nfunc (m Model) TagProperty() (length []float64, area []float64)\n    TagProperty return length of lines, area of triangles for each tag. Arcs are\n    ignored\n\nfunc (m Model) Write(filename string) (err error)\n    Write model into file with filename in JSON format\n\ntype OrientationPoints int8\n    OrientationPoints is orientation points state\n\nfunc Orientation(p1, p2, p3 Point) OrientationPoints\n\nfunc Orientation128(p1, p2, p3 Point) OrientationPoints\n\ntype Point struct {\n\tX, Y float64\n}\n    Point is store of point coordinates\n\nfunc ConvexHull(points []Point, withoutCollinearPoints bool) (chain []int, res []Point)\n    ConvexHull return chain of convex points\n\nfunc MiddlePoint(p0, p1 Point) Point\n    MiddlePoint calculate middle point precisionally.\n\nfunc MirrorPoint(mp0, mp1 Point, sp ...Point) (\n\tmp []Point,\n\terr error,\n)\n    MirrorPoint return mirror point by line\n\nfunc Rotate(xc, yc, angle float64, point Point) (p Point)\n    Rotate point about (xc,yc) on angle\n\nfunc (p Point) String() string\n    String is implementation of Stringer implementation for formating output\n\ntype Point3d [3]float64\n    Point3d is point coordinate in 3D decart system\n\nfunc BorderPoints(ps ...Point3d) (min, max Point3d)\n    BorderPoints return (min..max) points coordinates\n\nfunc LineTriangle3dI1(\n\tl0, l1 Point3d,\n\tt0, t1, t2 Point3d,\n) (\n\tintersect bool,\n\tpi []Point3d,\n)\n    LineTriangle3dI1 return intersection points for case if line and triangle is\n    not on one plane. line intersect triangle in one point\n\nfunc LineTriangle3dI2(\n\tl0, l1 Point3d,\n\tt0, t1, t2 Point3d,\n) (\n\tintersect bool,\n\tpi []Point3d,\n)\n    LineTriangle3dI2 return intersection points if line and triangle located on\n    one plane. Line on triangle plane Line is not zero ignore triangle point on\n    line\n\nfunc Mirror3d(plane [3]Point3d, points ...Point3d) (mir []Point3d)\n    Mirror3d return mirror points by mirror plane\n\nfunc PointLineRatio3d(\n\tl0, l1 Point3d,\n\tratio float64,\n) (\n\tp Point3d,\n)\n    PointLineRatio3d return point in accroding to line ratio\n\nfunc TriangleTriangle3d(\n\ta0, a1, a2 Point3d,\n\tb0, b1, b2 Point3d,\n) (\n\tintersect bool,\n\tpi []Point3d,\n)\n    TriangleTriangle3d return intersection points between two triangles.\n    do not intersect with egdes\n\ntype State int64\n    State is result of intersection\n\nconst (\n\n\t// VerticalSegment return if segment is vertical\n\tVerticalSegment State\n\n\t// HorizontalSegment return if segment is horizontal\n\tHorizontalSegment\n\n\t// ZeroLengthSegment return for zero length segment\n\tZeroLengthSegment\n\n\t// Parallel is segment A and segment B.\n\t// Intersection point data is not valid.\n\tParallel\n\n\t// Collinear return if:\n\t// Segment A and segment B are collinear.\n\t// Intersection point data is not valid.\n\tCollinear\n\n\t// OnSegment is intersection point on segment\n\tOnSegment\n\n\t// OnPoint0Segment intersection point on point 0 segment\n\tOnPoint0Segment\n\n\t// OnPoint1Segment intersection point on point 1 segment\n\tOnPoint1Segment\n\n\t// ArcIsLine return only if wrong arc is line\n\tArcIsLine\n\n\t// ArcIsPoint return only if wrong arc is point\n\tArcIsPoint\n)\nfunc (s State) Has(si State) bool\n    Has is mean s-State has si-State\n\nfunc (s State) Not(si State) bool\n    Not mean s-State have not si-State\n\nfunc (s State) String() string\n    String is implementation of Stringer implementation for formating output\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonstantin8105%2Fgog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonstantin8105%2Fgog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonstantin8105%2Fgog/lists"}