Point2i.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // Point2i.h
  3. //
  4. // Created by Giles Payne on 2019/10/09.
  5. //
  6. #pragma once
  7. #ifdef __cplusplus
  8. #import "opencv2/core.hpp"
  9. #else
  10. #define CV_EXPORTS
  11. #endif
  12. #import <Foundation/Foundation.h>
  13. @class Rect2i;
  14. NS_ASSUME_NONNULL_BEGIN
  15. /**
  16. * Represents a two dimensional point the coordinate values of which are of type `int`
  17. */
  18. CV_EXPORTS @interface Point2i : NSObject
  19. # pragma mark - Properties
  20. @property int x;
  21. @property int y;
  22. #ifdef __cplusplus
  23. @property(readonly) cv::Point2i& nativeRef;
  24. #endif
  25. # pragma mark - Constructors
  26. - (instancetype)init;
  27. - (instancetype)initWithX:(int)x y:(int)y;
  28. - (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
  29. #ifdef __cplusplus
  30. + (instancetype)fromNative:(cv::Point2i&)point;
  31. - (void)update:(cv::Point2i&)point;
  32. #endif
  33. # pragma mark - Methods
  34. /**
  35. * Calculate the dot product of this point and another point
  36. * @param point The other point
  37. */
  38. - (double)dot:(Point2i*)point;
  39. /**
  40. * Determine if the point lies with a specified rectangle
  41. * @param rect The rectangle
  42. */
  43. - (BOOL)inside:(Rect2i*)rect;
  44. /**
  45. * Set the point coordinates from the values of an array
  46. * @param vals The array of values from which to set the coordinates
  47. */
  48. - (void)set:(NSArray<NSNumber*>*)vals NS_SWIFT_NAME(set(vals:));
  49. # pragma mark - Common Methods
  50. /**
  51. * Clone object
  52. */
  53. - (Point2i*)clone;
  54. /**
  55. * Compare for equality
  56. * @param other Object to compare
  57. */
  58. - (BOOL)isEqual:(nullable id)other;
  59. /**
  60. * Calculate hash value for this object
  61. */
  62. - (NSUInteger)hash;
  63. /**
  64. * Returns a string that describes the contents of the object
  65. */
  66. - (NSString*)description;
  67. @end
  68. NS_ASSUME_NONNULL_END