Latest 0.1.0
Homepage https://github.com/srinija/SAGeometry
License MIT
Platforms ios 8.0
Frameworks UIKit

CI Status
Version
License
Platform

Usage

These are the functions availabe right now:

Lines and Points:

distanceBetweenPoints(point1: CGPoint, point2: CGPoint) -> CGFloat
getAngleBetweenPoints(p1:CGPoint, p2: CGPoint, p3:CGPoint) -> Double
getAngleBetweenPointsInDegrees(p1:CGPoint, p2: CGPoint, p3:CGPoint) -> Double
arePointsCollinear(points:[CGPoint]) -> Bool
shortestDistanceBetweenLineAndPoint(point:CGPoint, l1:CGPoint, l2:CGPoint) -> CGFloat
isPointOnLine(point:CGPoint, l1:CGPoint, l2:CGPoint) -> Bool
doLineSegmentsIntersect(l1:CGPoint, l2:CGPoint, m1:CGPoint, m2:CGPoint) -> Bool

Qudrilaterals:

isQuadrilateral(points:[CGPoint])
reorderToConvexQuadrilateral(corners:[CGPoint]) -> [CGPoint]?
getCGRectFromPoints(topLeft: CGPoint,topRight: CGPoint,bottomRight: CGPoint,bottomLeft: CGPoint) -> CGRect?
isConvex(corners:[CGPoint]) -> Bool
isConcave(corners:[CGPoint]) -> Bool
isQuadrilateralRectangle(corners:[CGPoint]) -> Bool
isQuadrilateralSquare(corners:[CGPoint]) -> Bool
isQuadrilateralRhombus(corners:[CGPoint]) -> Bool

Circles:

isPointInsideCircle(point:CGPoint, center:CGPoint, radius:CGFloat) -> Bool
isPointOnCircle(point:CGPoint, center:CGPoint, radius:CGFloat) -> Bool

Polygons:

isPointOnPolygon(point:CGPoint, polygon:[CGPoint]) -> Bool
isPointInsidePolygon(point:CGPoint, polygon:[CGPoint]) -> Bool

More functions on the way!

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Move the different points in the example around to see various functions being used.

Demo GIF

Installation

CocoaPods

To install with CocoaPods, simply add the following line to your Podfile:

pod 'SAGeometry'

Manual

Add the ‘SAGeometry.swift file into your project

Author

Srinija Ammapalli

License

SAGeometry is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SAGeometry",
    "version": "0.1.0",
    "summary": "A geometry helper for core graphics written in swift.",
    "homepage": "https://github.com/srinija/SAGeometry",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": "Srinija Ammapalli",
    "source": {
        "git": "https://github.com/srinija/SAGeometry.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "SAGeometry/Classes/**/*",
    "frameworks": "UIKit",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This