Skip to content

Instantly share code, notes, and snippets.

@giginet
Created February 25, 2018 12:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giginet/486b5950185de202750f7c8558d9e9ff to your computer and use it in GitHub Desktop.
Save giginet/486b5950185de202750f7c8558d9e9ff to your computer and use it in GitHub Desktop.
diff --git a/DemoBots/GeometryExtensions.swift b/DemoBots/GeometryExtensions.swift
index 5c5f97c..e5dc712 100644
--- a/DemoBots/GeometryExtensions.swift
+++ b/DemoBots/GeometryExtensions.swift
@@ -30,12 +30,6 @@ extension float2 {
}
}
-/*
- Extend `float2` to declare conformance to the `Equatable` protocol.
- The conformance to the protocol is provided by the `==` operator function below.
-*/
-extension float2: Equatable {}
-
/// An equality operator function to determine if two `float2`s are the same.
public func ==(lhs: float2, rhs: float2) -> Bool {
return lhs.x == rhs.x && lhs.y == rhs.y
@@ -61,8 +55,8 @@ extension float2 {
let componentInSegment = projectionAlongSegment / lineLengthSquared
// Clamps the component between [0 - 1].
- let fractionOfComponent = max(0, min(1, componentInSegment))
+ let fractionOfComponent = Swift.max(0, Swift.min(1.0, componentInSegment))
return lineSegment.startPoint + lineSegmentVector * fractionOfComponent
}
-}
\ No newline at end of file
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment