mirror of
https://github.com/zhigang1992/PerspectiveTransform.git
synced 2026-04-30 21:22:04 +08:00
cleanup self.
This commit is contained in:
@@ -20,7 +20,7 @@ class PerformanceTest: XCTestCase {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.measure {
|
measure {
|
||||||
stride(from:0, to: 100000, by: 1).forEach { _ in
|
stride(from:0, to: 100000, by: 1).forEach { _ in
|
||||||
_ = start.projectiveTransform(destination: destination)
|
_ = start.projectiveTransform(destination: destination)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ extension Matrix3x3Type {
|
|||||||
|
|
||||||
func homogeneousInverse() -> Matrix3x3Type {
|
func homogeneousInverse() -> Matrix3x3Type {
|
||||||
#if arch(arm64) || arch(x86_64)
|
#if arch(arm64) || arch(x86_64)
|
||||||
let result = self.inverse
|
let result = inverse
|
||||||
#else
|
#else
|
||||||
let result = adjugate()
|
let result = adjugate()
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,21 +17,21 @@ public final class Perspective {
|
|||||||
|
|
||||||
lazy var basisVectorsToPointsMap: Matrix3x3Type! = {
|
lazy var basisVectorsToPointsMap: Matrix3x3Type! = {
|
||||||
let m = Matrix3x3Type([
|
let m = Matrix3x3Type([
|
||||||
self.vectors[0],
|
vectors[0],
|
||||||
self.vectors[1],
|
vectors[1],
|
||||||
self.vectors[2]]
|
vectors[2]]
|
||||||
)
|
)
|
||||||
let solution = m.homogeneousInverse() * self.vectors[3]
|
let solution = m.homogeneousInverse() * vectors[3]
|
||||||
let scale = Matrix3x3Type(diagonal: solution)
|
let scale = Matrix3x3Type(diagonal: solution)
|
||||||
let basisToPoints = m * scale
|
let basisToPoints = m * scale
|
||||||
return basisToPoints.zNormalized()
|
return basisToPoints.zNormalized()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
lazy var pointsToBasisVectorsMap: Matrix3x3Type! = {
|
lazy var pointsToBasisVectorsMap: Matrix3x3Type! = {
|
||||||
self.basisVectorsToPointsMap.homogeneousInverse()
|
basisVectorsToPointsMap.homogeneousInverse()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
internal func projection(to:Perspective) -> Matrix3x3Type {
|
internal func projection(to:Perspective) -> Matrix3x3Type {
|
||||||
return (to.basisVectorsToPointsMap * pointsToBasisVectorsMap).zNormalized()
|
return (to.basisVectorsToPointsMap * pointsToBasisVectorsMap).zNormalized()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user