Double2.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // Double2.h
  3. //
  4. // Created by Giles Payne on 2020/05/22.
  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 Mat;
  14. NS_ASSUME_NONNULL_BEGIN
  15. /**
  16. * Simple wrapper for a vector of two `double`
  17. */
  18. CV_EXPORTS @interface Double2 : NSObject
  19. #pragma mark - Properties
  20. /**
  21. * First vector element
  22. */
  23. @property double v0;
  24. /**
  25. * Second vector element
  26. */
  27. @property double v1;
  28. #ifdef __cplusplus
  29. /**
  30. * The wrapped vector
  31. */
  32. @property(readonly) cv::Vec2d& nativeRef;
  33. #endif
  34. #pragma mark - Constructors
  35. /**
  36. * Create zero-initialize vecior
  37. */
  38. -(instancetype)init;
  39. /**
  40. * Create vector with specified element values
  41. * @param v0 First element
  42. * @param v1 Second element
  43. */
  44. -(instancetype)initWithV0:(double)v0 v1:(double)v1;
  45. /**
  46. * Create vector with specified element values
  47. * @param vals array of element values
  48. */
  49. -(instancetype)initWithVals:(NSArray<NSNumber*>*)vals;
  50. #ifdef __cplusplus
  51. +(instancetype)fromNative:(cv::Vec2d&)vec2d;
  52. #endif
  53. /**
  54. * Update vector with specified element values
  55. * @param vals array of element values
  56. */
  57. -(void)set:(NSArray<NSNumber*>*)vals NS_SWIFT_NAME(set(vals:));
  58. /**
  59. * Get vector as an array
  60. */
  61. -(NSArray<NSNumber*>*)get;
  62. #pragma mark - Common Methods
  63. /**
  64. * Compare for equality
  65. * @param other Object to compare
  66. */
  67. -(BOOL)isEqual:(nullable id)other;
  68. @end
  69. NS_ASSUME_NONNULL_END