BNBTransformation

Objective-C

@interface BNBTransformation : NSObject

/** Constructs identity transform */
+ (nullable BNBTransformation *)makeIdentity;

/** Constructs from mat_t */
+ (nullable BNBTransformation *)makeData:(nonnull NSArray<NSNumber *> *)mat;

/** Constructs rotate transformation */
+ (nullable BNBTransformation *)makeRot:(BNBRotation)rot;

/** Constructs affine transformation */
+ (nullable BNBTransformation *)makeAffine:(float)scaleX
                                    scaleY:(float)scaleY
                                        tX:(float)tX
                                        tY:(float)tY
                                       rot:(BNBRotation)rot
                                     flipX:(BOOL)flipX
                                     flipY:(BOOL)flipY;

/**
 * Constructs transformation from source to target rectangle
 * Rotation and flips are around rectangles' center
 */
+ (nullable BNBTransformation *)makeRects:(nonnull BNBPixelRect *)sourceRect
                               targetRect:(nonnull BNBPixelRect *)targetRect
                                      rot:(BNBRotation)rot
                                    flipX:(BOOL)flipX
                                    flipY:(BOOL)flipY;

/**
 * Applies transform t after this
 * e.g. {rotate >> translate;} rotates first: (initial -> rotated) >> (rotated -> translated) = (initial -> translated)
 */
- (nullable BNBTransformation *)chainRight:(nullable BNBTransformation *)t;

/** Apply transform to point */
- (nonnull BNBPoint2d *)transformPoint:(nonnull BNBPoint2d *)p;

- (nonnull BNBPixelRect *)transformRect:(nonnull BNBPixelRect *)rect;

- (BOOL)equals:(nullable BNBTransformation *)t;

/**
 * Get the inverse of the transformation
 * @throw std::logic_error when matrix is singular
 */
- (nullable BNBTransformation *)inverseJ;

/** Clone the transformation */
- (nullable BNBTransformation *)cloneJ;

/** Returns 3x3 row-maj transform matrix */
- (nonnull NSArray<NSNumber *> *)getMatJ;

@end

Swift

class BNBTransformation : NSObject

Undocumented

  • Constructs identity transform

    Declaration

    Objective-C

    + (nullable BNBTransformation *)makeIdentity;

    Swift

    class func makeIdentity() -> BNBTransformation?
  • Constructs from mat_t

    Declaration

    Objective-C

    + (nullable BNBTransformation *)makeData:(nonnull NSArray<NSNumber *> *)mat;

    Swift

    class func makeData(_ mat: [NSNumber]) -> BNBTransformation?
  • Constructs rotate transformation

    Declaration

    Objective-C

    + (nullable BNBTransformation *)makeRot:(BNBRotation)rot;

    Swift

    class func makeRot(_ rot: BNBRotation) -> BNBTransformation?
  • Constructs affine transformation

    Declaration

    Objective-C

    + (nullable BNBTransformation *)makeAffine:(float)scaleX
                                        scaleY:(float)scaleY
                                            tX:(float)tX
                                            tY:(float)tY
                                           rot:(BNBRotation)rot
                                         flipX:(BOOL)flipX
                                         flipY:(BOOL)flipY;

    Swift

    class func makeAffine(_ scaleX: Float, scaleY: Float, tX: Float, tY: Float, rot: BNBRotation, flipX: Bool, flipY: Bool) -> BNBTransformation?
  • Constructs transformation from source to target rectangle Rotation and flips are around rectangles’ center

    Declaration

    Objective-C

    + (nullable BNBTransformation *)makeRects:(nonnull BNBPixelRect *)sourceRect
                                   targetRect:(nonnull BNBPixelRect *)targetRect
                                          rot:(BNBRotation)rot
                                        flipX:(BOOL)flipX
                                        flipY:(BOOL)flipY;

    Swift

    class func makeRects(_ sourceRect: BNBPixelRect, targetRect: BNBPixelRect, rot: BNBRotation, flipX: Bool, flipY: Bool) -> BNBTransformation?
  • Applies transform t after this e.g. {rotate >> translate;} rotates first: (initial -> rotated) >> (rotated -> translated) = (initial -> translated)

    Declaration

    Objective-C

    - (nullable BNBTransformation *)chainRight:(nullable BNBTransformation *)t;

    Swift

    func chainRight(_ t: BNBTransformation?) -> BNBTransformation?
  • Apply transform to point

    Declaration

    Objective-C

    - (nonnull BNBPoint2d *)transformPoint:(nonnull BNBPoint2d *)p;

    Swift

    func transformPoint(_ p: BNBPoint2d) -> BNBPoint2d
  • Undocumented

    Declaration

    Objective-C

    - (nonnull BNBPixelRect *)transformRect:(nonnull BNBPixelRect *)rect;

    Swift

    func transform(_ rect: BNBPixelRect) -> BNBPixelRect
  • Undocumented

    Declaration

    Objective-C

    - (BOOL)equals:(nullable BNBTransformation *)t;

    Swift

    func equals(_ t: BNBTransformation?) -> Bool
  • Get the inverse of the transformation @throw std::logic_error when matrix is singular

    Declaration

    Objective-C

    - (nullable BNBTransformation *)inverseJ;

    Swift

    func inverseJ() -> BNBTransformation?
  • Clone the transformation

    Declaration

    Objective-C

    - (nullable BNBTransformation *)cloneJ;

    Swift

    func cloneJ() -> BNBTransformation?
  • Returns 3x3 row-maj transform matrix

    Declaration

    Objective-C

    - (nonnull NSArray<NSNumber *> *)getMatJ;

    Swift

    func getMatJ() -> [NSNumber]