-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlateTree.m
42 lines (35 loc) · 964 Bytes
/
PlateTree.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
classdef PlateTree
properties
max_x
min_x
max_y
min_y
Node1
Node2
Node3
Node4
centroid
area
end
methods
% constructor
function obj = Box(x_min, x_max,y_min,y_max)
obj.x_min = x_min
obj.x_max = x_max
obj.y_min = y_min
obj.Node4 = y_max
obj.centroid = obj.calculate_centroid();
obj.area = obj.calculate_Area();
end
% Calculate midpoint of diagonal
function diagonalMidpoint= calculate_centroid(obj)
diagonalMidpoint = 0.5 * (obj.Node1 + obj.Node3);
end
% Calculate area of the box
function area_2D = calculate_Area(obj)
side1 = norm(obj.Node1 - obj.Node2);
side2 = norm(obj.Node3 - obj.Node4);
area_2D = side1 * side2;
end
end
end