1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00
Files
opencv/modules/core/misc/objc/common/Point3f.mm
T
Giles Payne 02385472b6 Merge pull request #17165 from komakai:objc-binding
Objc binding

* Initial work on Objective-C wrapper

* Objective-C generator script; update manually generated wrappers

* Add Mat tests

* Core Tests

* Imgproc wrapper generation and tests

* Fixes for Imgcodecs wrapper

* Miscellaneous fixes. Swift build support

* Objective-C wrapper build/install

* Add Swift wrappers for videoio/objdetect/feature2d

* Framework build;iOS support

* Fix toArray functions;Use enum types whenever possible

* Use enum types where possible;prepare test build

* Update test

* Add test runner scripts for iOS and macOS

* Add test scripts and samples

* Build fixes

* Fix build (cmake 3.17.x compatibility)

* Fix warnings

* Fix enum name conflicting handling

* Add support for document generation with Jazzy

* Swift/Native fast accessor functions

* Add Objective-C wrapper for calib3d, dnn, ml, photo and video modules

* Remove IntOut/FloatOut/DoubleOut classes

* Fix iOS default test platform value

* Fix samples

* Revert default framework name to opencv2

* Add converter util functions

* Fix failing test

* Fix whitespace

* Add handling for deprecated methods;fix warnings;define __OPENCV_BUILD

* Suppress cmake warnings

* Reduce severity of "jazzy not found" log message

* Fix incorrect #include of compatibility header in ios.h

* Use explicit returns in subscript/get implementation

* Reduce minimum required cmake version to 3.15 for Objective-C/Swift binding
2020-06-08 18:32:53 +00:00

112 lines
2.2 KiB
Plaintext

//
// Point3f.mm
//
// Created by Giles Payne on 2019/10/09.
//
#import "Point3f.h"
#import "Point2f.h"
#import "CVObjcUtil.h"
@implementation Point3f {
cv::Point3f native;
}
- (float)x {
return native.x;
}
- (void)setX:(float)val {
native.x = val;
}
- (float)y {
return native.y;
}
- (void)setY:(float)val {
native.y = val;
}
- (float)z {
return native.z;
}
- (void)setZ:(float)val {
native.z = val;
}
- (cv::Point3f&)nativeRef {
return native;
}
- (instancetype)init {
return [self initWithX:0 y:0 z:0];
}
- (instancetype)initWithX:(float)x y:(float)y z:(float)z {
self = [super init];
if (self) {
self.x = x;
self.y = y;
self.z = z;
}
return self;
}
- (instancetype)initWithPoint:(Point2f*)point {
return [self initWithX:point.x y:point.y z:0];
}
- (instancetype)initWithVals:(NSArray<NSNumber*>*)vals {
self = [super init];
if (self) {
[self set:vals];
}
return self;
}
- (void)set:(NSArray<NSNumber*>*)vals {
self.x = (vals != nil && vals.count > 0) ? vals[0].floatValue : 0.0;
self.y = (vals != nil && vals.count > 1) ? vals[1].floatValue : 0.0;
self.z = (vals != nil && vals.count > 2) ? vals[2].floatValue : 0.0;
}
- (Point3f*) clone {
return [[Point3f alloc] initWithX:self.x y:self.y z:self.z];
}
- (double)dot:(Point3f*)point {
return self.x * point.x + self.y * point.y + self.z * point.z;
}
- (Point3f*)cross:(Point3f*)point {
return [[Point3f alloc] initWithX:(self.y * point.z - self.z * point.y) y:(self.z * point.x - self.x * point.z) z:(self.x * point.y - self.y * point.x)];
}
- (BOOL)isEqual:(id)other {
if (other == self) {
return YES;
} else if (![other isKindOfClass:[Point3f class]]) {
return NO;
} else {
Point3f* point = (Point3f*)other;
return self.x == point.x && self.y == point.y && self.z == point.z;
}
}
- (NSUInteger)hash {
int prime = 31;
uint32_t result = 1;
result = prime * result + FLOAT_TO_BITS(self.x);
result = prime * result + FLOAT_TO_BITS(self.y);
result = prime * result + FLOAT_TO_BITS(self.z);
return result;
}
- (NSString *)description {
return [NSString stringWithFormat:@"Point3f {%f,%f,%f}", self.x, self.y, self.z];
}
@end