A Geometrical library for Go Language
Gogeom
A Geometrical library for the Go programming language.
This is a Geometrical library for Go Language. Which includes multiple Geometrical calculations like Circle, Lines etc in different forms.
This is a Geometrical library for Go Language.
Which includes multiple Geometrical calculations like Circle, Lines etc in different forms.
Installation
Installation is done using go get
.
go get u github.com/MindorksOpenSource/gogeom
These are following shape calculation which is supported by gogeom.
 [x] Circle
 [x] Line
 [x] Ellipse
 [x] Parabola
 [ ] more to come..
Circle
gogeom can handle two form of Circle.
 Radius Form
(xa)^2 + (yb)^2 = r^2 where, (a,b) is the center and "r" is the radius of the circle
 General Form
x2 + y2 + Ax + By+ C = 0 where, A,B and C are real numbers
Step to follow :
 import
shape "github.com/MindorksOpenSource/gogeom"
 Initalize two circles as (in Radius Form),
import geometry "github.com/MindorksOpenSource/gogeom"
func main() {
// (xa)^2 + (yb)^2 = r^2 and (xc)^2 + (yd)^2 = s^2 are circle equation
// r, s are radius of two circles
r := shape.RadiusFormCircle{
// a, b , r , c, d, s
2, 3, 4, 5, 6, 7,
}
}
 Initalize two circles as (in General Form),
import `shape "github.com/MindorksOpenSource/gogeom"
func main() {
// x2 + y2 + Ax + By+ C = 0 and x2 + y2 + Dx + Ey + F = 0 are circle equation
g := shape.GeneralFormOfCircle{
// a, b , r , c, d, s
2, 3, 4, 5, 6, 7,
}
}
Calculations for Circles
Working  Radius Form  General Form 

Distance between two centers of circles  r.DistanceBetweenTwoCenters()  g.DistanceBetweenTwoCenters() 
Line Equation Connecting Two Centers  r.LineEquationConnectingTwoCenters()  g.LineEquationConnectingTwoCenters() 
Check if both Circles Intersect  r.DoesCircleIntersect()  
Check if both Circles does not Intersect  r.AreTwoNonIntersectingCircle()  
Area of Circle1 and Circle2  r.AreaOfCircles()  
Circumference of Circle1 and Circle2  r.CircumferenceOfCircles()  
∂ is the area of the triangle formed by the two circle centers and one of the intersection point. The sides of this triangle are S, r0 and R0 , the area is calculated by Heron' s formula.  r.CalculateDelta()  
Calculates x1,y1,x2,y2  r.CalculateXY()  
Calculates x1,y1  r.CalculateAB()  
Calculates x2,y2  r.CalculateCD()  
Calculates x1,x2  r.CalculateXs()  
Calculates y1,y2  r.CalculateYs()  
Calculates the Line Equation connecting both intersection points  r.LineEquationConnectingTwoIntersectionPoint()  g.LineEquationConnectingTwoIntersectionPoint() 
Check if Both Circles Touch Each other as tangent  r.IsTangent()  g.IsTangent() 
Check if two circles has Outer Circle Tangency  r.IsOuterCircleTangency()  
Check if two circle has Inner Circle Tangency  r.IsInnerCircleTangency()  
Tangential Points  r.TangentPoint()  g.TangentPoint() 
Slope of Line of Intersection Point  r.SlopeOfConnectingLineOfTwoIntersectionPoint()  g.SlopeOfConnectingLineOfTwoIntersectionPoint() 
Radius of Both Circls R1,R2  g.RadiusOfTwoCircle() 
Line
gogeom can handle two form of Line.

General Form
Ax+By+C =0 where A, B and C are any real number and A and B are not both zero.```

Two Point Form
(x1,y1) and (x2,y2) form two lines passing through it
Step to follow :

import
shape "github.com/MindorksOpenSource/gogeom"

Initalize two lines as (in General Form),
// initialise one line
l := shape.GeneralLine{
// a, b, c
2, 3, 4,
}
}
 or if you have to initialise multiple line 
l := shape.GeneralLines{
// a, b, c, d, e, f
2, 3, 4, 5, 6, 7,
}
}
 or if you have two point line 
l := shape.GeneralLines{
// a, b, c, d, e, f
2, 3, 4, 5,
}
}
 Initalize two lines as (in Two Point Form Line Form),
Calculations for Line
Working  General Form (Single Line)  General Form (Multiple Lines)  Two Point Form 

Slope of Line  l.SlopeOfLine()  l.SlopeOfLine()  
YIntercept  l.YIntercept()  
XIntercept  l.XIntercept()  
MidPoint of the line  l.MidPoints()  
Intersection of two lines Ax + By + C = 0 and Dx + Ey + F = 0  l.IntersectionOfLines()  
Point (x, y) which divides the line connecting two points (x1 , y1) and (x2 , y2) in the ratio p:q  l.DividingPoints(p,q)  
Point (x, y) which divides the line connecting two points (x1 , y1) and (x2 , y2) externally in the ratio p:q  l.ExternalDividingPoints(p,q)  
Angle Between Two Lines  l.AngleBetweenTwoLines()  
Line Eqn passing two points  l.LineThroughTwoPoint()  
EquiDistant Parallel Line  l.EquiDistantParallelLine()  
Distance Between Two Points  l.DistanceBetweenTwoPoints()  
Distance Between Intercepts  l.DistanceBetweenInterecepts() 
Ellipse
Ellipse Equation,
x^2/a^2 + y^2/b^2 = 1,
(center at x = 0 y = 0)
Step to follow :
 import
shape "github.com/MindorksOpenSource/gogeom"
 Initalize ellipse,
e := shape.Ellipse {
// a, b
1,2
}
Working  General Form (Single Line)  Result 

Eccentricity of Ellipse  e.GetEccentricity()  float64 
Shape Of Locus  e.GetShapeOfLocus()  Circle/Ellipse/Parabola/Hyerbola 
Slope Of Tangent Line at x1,y1  e.GetSlopeOfTangentLine(x1,y1)  float64 
Tangent Line Equation at x1,y1  e.GetTangentLineEquation(x1,y1)  string 
Ramanujan Approx Circumference of ellipse  e.RamanujanApproxCircumference()  float64 
Parabola
Gogeom can support two form
 Equation of Parabola
y^2 = 4ax
or
x^2 = 4ay
or
(y  k)^2 = 4a(x  h)
where, (h,k) are vertex
or
(x  h)^2 = 4a(y  k)
where, (h,k) are vertex
 import
shape "github.com/MindorksOpenSource/gogeom"
 Initalize Parabola,
p := shape.Parabola {
1,
true // where this boolean value indicates if the parabola is on YAxis or not.
}
 or 
p :=shape.Parabola {
1,
true // where this boolean value indicates if the parabola is on YAxis or not.
}
Step to follow :
Working  Parabola With Origin  Parabola  Result 

Lenght Of Latus Ration  p.LenghtOfLatusRation()  p.LenghtOfLatusRation()  float64 
Focus  p.FocusOfParabola()  p.FocusOfParabola()  float64,float64 
Directrix Equation  p.DirectrixEquation()  p.DirectrixEquation()  string 
Axis Equation  p.AxisEquation()  p.AxisEquation()  string 
Vertex  p.Vertex()  string  
Position Of Point  x,y  p.PositionOfPoint(x,y)  string  
Point Of Interesction  y = mx + c  p.PointOfInteresction(m,c)  string  
Tangent Equation  x,y  p.TangentEquation(x,y)  string  
Normal Equation  x,y  p.NormalEquation(x,y)  string  
Chord Of Contact Equation  x,y  p.ChordOfContactEquation(x,y)  string  
Polar Of Point  x,y  p.PolarOfPoint(x,y)  string  
Pole Of line  lx + my + x = 0  p.PoleOfline(l,m)  float64, float64 