-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects.py
102 lines (82 loc) · 2.82 KB
/
objects.py
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import random
class Object:
"""
Represents an object in the octree.
Each object is assumed to be a sphere for simplicity,
but this representation can be extended to other shapes
using techniques like the union of spheres.
Attributes:
x (float): X-coordinate of the object's position.
y (float): Y-coordinate of the object's position.
z (float): Z-coordinate of the object's position.
fixed (bool): Indicates whether the object is fixed in place.
id (int or None): Unique identifier for the object.
object_to_node_map (dictionary): Mapping between Object and node_id
"""
def __init__(self, position):
"""
Initialize an object with a given position.
Args:
position (tuple): Tuple containing the x, y, and z coordinates of the object.
"""
self.x, self.y, self.z = position
self.fixed = False # Initialize fixed attribute to False
self.id = None # Initialize the id attribute
self.node_id = None # Initialize the node_id attribute
# self.object_to_node_map = {} # Initialize the object to node mapping
def getX(self):
"""
Get the x-coordinate of the object's position.
Returns:
float: X-coordinate of the object.
"""
return self.x
def getY(self):
"""
Get the y-coordinate of the object's position.
Returns:
float: Y-coordinate of the object.
"""
return self.y
def getZ(self):
"""
Get the z-coordinate of the object's position.
Returns:
float: Z-coordinate of the object.
"""
return self.z
def is_fixed(self):
"""
Check if the object is fixed.
Returns:
bool: True if the object is fixed, False otherwise.
"""
return self.fixed
def set_fixed(self, value):
"""
Set the fixed attribute of the object.
Args:
value (bool): New value for the fixed attribute.
"""
self.fixed = value
def set_id(self, id_value):
"""
Set the id of the object.
Args:
id_value (int or None): New identifier for the object.
"""
self.id = id_value
# def set_node_id(self, node_id):
# """
# Set the node ID for the object.
# Args:
# node_id (int): Node ID to associate with the object.
# """
# self.object_to_node_map[self.id] = node_id
# def get_node_id(self):
# """
# Get the node ID associated with the object.
# Returns:
# int or None: Node ID associated with the object, or None if not mapped.
# """
# return self.object_to_node_map.get(self.id)