mirror of
https://github.com/zhigang1992/PerspectiveTransform.git
synced 2026-04-29 20:55:21 +08:00
refactor float3x3+3D
This commit is contained in:
@@ -32,6 +32,6 @@ public extension Quadrilateral {
|
||||
public func projectiveTransform(quad:Quadrilateral) -> CATransform3D {
|
||||
let projection = general2DProjection(quad)
|
||||
print(projection)
|
||||
return CATransform3D(projection)
|
||||
return CATransform3D(projection.to3d())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import QuartzCore
|
||||
import simd
|
||||
|
||||
extension CATransform3D {
|
||||
extension float3x3 {
|
||||
static let addColumn : float4x3 = {
|
||||
var m = float4x3(diagonal:float3(1,1,0))
|
||||
m[3,2] = 1
|
||||
@@ -22,9 +22,9 @@ extension CATransform3D {
|
||||
return m
|
||||
}()
|
||||
|
||||
init(_ m: float3x3) {
|
||||
var result = CATransform3D.addRow * m * CATransform3D.addColumn
|
||||
func to3d() -> float4x4 {
|
||||
var result = float3x3.addRow * self * float3x3.addColumn
|
||||
result[2,2] = 1
|
||||
self.init(result)
|
||||
return result
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user