Skip to content

Commit

Permalink
removed the use of zeroTangentVector from PinholeCamera (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
acoadmarmon authored Jan 19, 2021
1 parent 9eca609 commit 58a29e7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Sources/SwiftFusion/Geometry/Cal3_S2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ extension Cal3_S2: CameraCalibration {
}
}

extension Cal3_S2 {
public func zeroTangentVector() -> Cal3_S2.TangentVector {
return Vector5(0.0, 0.0, 0.0, 0.0, 0.0)
}
}

/// Manifold coordinate for Cal3_S2.
public struct Cal3_S2Coordinate: Equatable {
Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftFusion/Geometry/CameraCalibration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ public protocol CameraCalibration: Differentiable {
/// Converts from normalized coordinate to image coordinate.
@differentiable
func uncalibrate(_ np: Vector2) -> Vector2

func zeroTangentVector() -> TangentVector
}
2 changes: 1 addition & 1 deletion Sources/SwiftFusion/Geometry/PinholeCamera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ extension PinholeCamera {
p.x * (R[0, 2] - u * R[2, 2]) + p.y * (R[1, 2] - v * R[2, 2]))

return (
TangentVector(wTc: dpose, calibration: calibration.zeroTangentVector),
TangentVector(wTc: dpose, calibration: calibration.zeroTangentVector()),
dpoint)
}
)
Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftFusionTests/Geometry/PinholeCameraTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ final class PinholeCameraTests: XCTestCase {
let dxExpected = (
PinholeCamera<Cal3_S2>.TangentVector(
wTc: Vector6(-1.0, -2.0, -1.0, -1.0, 0.0, 1.0),
calibration: K.zeroTangentVector),
calibration: K.zeroTangentVector()),
Vector3(1.0, 0.0, 1.0))
let dyExpected = (
PinholeCamera<Cal3_S2>.TangentVector(
wTc: Vector6(2.0, 1.0, -1.0, 0.0, -1.0, -1.0),
calibration: K.zeroTangentVector),
calibration: K.zeroTangentVector()),
Vector3(0.0, -1.0, -1.0))

assertAllKeyPathEqual(p, Vector2(1.0, -1.0), accuracy: 1e-10)
Expand Down

0 comments on commit 58a29e7

Please sign in to comment.