Skip to main content

EXTENSION

CGPoint

extension CGPoint

Methods​

applyingAffineTransform(containerSize:viewSize:transform:)​

public func applyingAffineTransform(containerSize: CGSize, viewSize: CGSize, transform: CGAffineTransform) -> CGPoint

Transforms a single point from the container coordinate space to the view coordinate space by:

  1. Normalizing the point relative to the container size,
  2. Applying an affine transform (assumed to map normalized coordinates),
  3. Scaling the result to the view size.
  • Parameters:
    • containerSize: The size of the container coordinate space.
    • viewSize: The size of the target view coordinate space.
    • transform: The affine transform to apply to normalized coordinates.
  • Returns: The transformed point in the view coordinate space.

Parameters​

NameDescription
containerSizeThe size of the container coordinate space.
viewSizeThe size of the target view coordinate space.
transformThe affine transform to apply to normalized coordinates.

applyingReprojection(containerSize:transform:)​

public func applyingReprojection(containerSize: CGSize, transform: simd_float3x3) -> CGPoint

Applies a 3x3 homography (reprojection) to this point.

  • Parameters:
    • containerSize: The size of the container coordinate space. Coordinates are assumed to be relative to this space (e.g., image or view size) when applying the homography.
    • transform: The 3x3 homography matrix that maps the point from the source coordinate space to the target coordinate space.
  • Returns: A new CGPoint transformed by the provided homography.

Parameters​

NameDescription
containerSizeThe size of the container coordinate space. Coordinates are assumed to be relative to this space (e.g., image or view size) when applying the homography.
transformThe 3x3 homography matrix that maps the point from the source coordinate space to the target coordinate space.