forked from natikgadzhi/XNMaths
-
Notifications
You must be signed in to change notification settings - Fork 1
/
XNBox.m
87 lines (68 loc) · 1.82 KB
/
XNBox.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// XNBox.m
// XNMaths
//
// XNBox class implementation
// XNBox class is a simple geometry boundary.
//
// Created by Нат Гаджибалаев on 01.12.09.
// Copyright 2009 Нат Гаджибалаев. All rights reserved.
//
#pragma mark -
#pragma mark Imports
#import "XNBox.h"
#import "XNFloatRange.h"
#pragma mark -
#pragma mark XNBox class implementation
@implementation XNBox
@synthesize xRange, yRange, zRange;
#pragma mark -
#pragma mark Class init methods
+ (XNBox*) boxWithRangesX: (XNFloatRange*)aXRange Y: (XNFloatRange*)aYRange Z: (XNFloatRange*)aZRange
{
return [[[XNBox alloc] initWithRangesX:aXRange Y:aYRange Z:aZRange] autorelease];
}
+ (XNBox*) boxWithXMin: (CGFloat)xMin XMax: (CGFloat)xMax YMin: (CGFloat)yMin YMax: (CGFloat)yMax ZMin: (CGFloat)zMin ZMax: (CGFloat)zMax
{
return [[[XNBox alloc] initWithXMin:xMin XMax:xMax YMin:yMin YMax:yMax ZMin:zMin ZMax:zMax] autorelease];
}
#pragma mark -
#pragma mark Instance init methods
- (XNBox*) initWithRangesX: (XNFloatRange*)aXRange Y: (XNFloatRange*)aYRange Z: (XNFloatRange*)aZRange
{
self = [super init];
xRange = [aXRange copy];
yRange = [aYRange copy];
zRange = [aZRange copy];
return self;
}
- (XNBox*) initWithXMin: (CGFloat)xMin XMax: (CGFloat)xMax YMin: (CGFloat)yMin YMax: (CGFloat)yMax ZMin: (CGFloat)zMin ZMax: (CGFloat)zMax
{
self = [super init];
xRange = [[XNFloatRange alloc] initWithMin:xMin max:xMax];
yRange = [[XNFloatRange alloc] initWithMin:yMin max:yMax];
zRange = [[XNFloatRange alloc] initWithMin:zMin max:zMax];
return self;
}
#pragma mark -
#pragma mark Instance methods
- (CGFloat) length
{
return [xRange length];
}
- (CGFloat) width
{
return [yRange length];
}
- (CGFloat) height
{
return [zRange length];
}
- (void) dealloc
{
[xRange release];
[yRange release];
[zRange release];
[super dealloc];
}
@end