Package pytilities :: Package geometry :: Module immutablevector
[hide private]
[frames] | no frames]

Source Code for Module pytilities.geometry.immutablevector

 1  # Copyright (C) 2010 Tim Diels <limyreth@users.sourceforge.net> 
 2  #  
 3  # This file is part of pytilities. 
 4  #  
 5  # pytilities is free software: you can redistribute it and/or modify 
 6  # it under the terms of the GNU General Public License as published by 
 7  # the Free Software Foundation, either version 3 of the License, or 
 8  # (at your option) any later version. 
 9  #  
10  # pytilities is distributed in the hope that it will be useful, 
11  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13  # GNU General Public License for more details. 
14  #  
15  # You should have received a copy of the GNU General Public License 
16  # along with pytilities.  If not, see <http://www.gnu.org/licenses/>. 
17  # 
18   
19  __docformat__ = 'reStructuredText' 
20   
21  from pytilities import AttributeCollectionBase 
22  from .vector import Vector 
23 24 -class ImmutableVector(AttributeCollectionBase):
25 26 """ 27 `Vector` wrapper that makes the vector immutable. 28 29 It supports all immutable attributes of `Vector`. All tries to mutate the 30 vector will result in exceptions. 31 32 For `Vector` specific documentation, see `Vector`. 33 """ 34
35 - def __init__(self, v):
36 """v:Vector -- the vector to wrap 37 """ 38 AttributeCollectionBase.__init__(self) 39 40 self.__v = v 41 42 # delegate to wrapped object 43 delegator = Vector.Delegator("immutable", v) 44 self._append_attribute_collection(delegator)
45 46 @property
47 - def x(self):
48 return self.__v.x
49 50 @x.setter
51 - def x(self, value):
52 assert False, "Tried to modify an immutable vector"
53 54 @property
55 - def y(self):
56 return self.__v.y
57 58 @y.setter
59 - def y(self, value):
60 assert False, "Tried to modify an immutable vector"
61 62 @property
63 - def length(self):
64 return abs(self)
65 66 @length.setter
67 - def length(self, value):
68 assert False, "Tried to modify an immutable vector"
69
70 - def move_to(self, *args):
71 assert False, "Tried to modify an immutable vector"
72
73 - def move_by(self, *args):
74 assert False, "Tried to modify an immutable vector"
75
76 - def assign(self, v):
77 assert False, "Tried to modify an immutable vector"
78
79 - def normalize(self):
80 assert False, "Tried to modify an immutable vector"
81
82 - def __isub__(self, other):
83 assert False, "Tried to modify an immutable vector"
84
85 - def __idiv__(self, other):
86 assert False, "Tried to modify an immutable vector"
87
88 - def __iadd__(self, other):
89 assert False, "Tried to modify an immutable vector"
90
91 - def __imul__(self, other):
92 assert False, "Tried to modify an immutable vector"
93