-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit_hash:1eed8ce8d0aa934f6ad22ae494bac4645dea378d
- Loading branch information
booster
committed
Oct 29, 2024
1 parent
acda693
commit 6353b89
Showing
15 changed files
with
414 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2024 Yandex LLC. All rights reserved. | ||
import Foundation | ||
|
||
import VGSLFundamentals | ||
|
||
extension CGVector { | ||
public init(_ point: CGPoint) { | ||
self.init(dx: point.x, dy: point.y) | ||
} | ||
|
||
public init(_ point1: CGPoint, _ point2: CGPoint) { | ||
self.init(dx: point2.x - point1.x, dy: point2.y - point1.y) | ||
} | ||
|
||
public func crossProductMagnitude(_ vector2: CGVector) -> CGFloat { | ||
dx * vector2.dy - dy * vector2.dx | ||
} | ||
|
||
public func dotProduct(_ vector2: CGVector) -> CGFloat { | ||
dx * vector2.dx + dy * vector2.dy | ||
} | ||
|
||
public var length: CGFloat { | ||
sqrt(dotProduct(self)) | ||
} | ||
|
||
public var normalized: CGVector { | ||
let length = self.length | ||
return CGVector(CGPoint(x: dx / length, y: dy / length)) | ||
} | ||
|
||
public func isClockwised(_ vector2: CGVector) -> Bool { | ||
crossProductMagnitude(vector2) > 0 | ||
} | ||
} |
Oops, something went wrong.