Skip to content

Commit 5d5367b

Browse files
committed
Reverting property annotations on Vec3 length() and normalized()
1 parent a7fdfca commit 5d5367b

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
4747

4848
# Example of using a sequence
4949
# This will do a front flip if the car's velocity is between 550 and 600
50-
if 550 < car_velocity.length < 600:
50+
if 550 < car_velocity.length() < 600:
5151
self.active_sequence = Sequence([
5252
ControlStep(0.05, SimpleControllerState(jump=True)),
5353
ControlStep(0.05, SimpleControllerState(jump=False)),

src/util/vec.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import math
22
from typing import Union
33

4+
from rlbot.utils.structures.game_data_struct import Vector3
5+
46

5-
# This is a helper class for vector math. You can extend it or delete if you want.
67
class Vec3:
78
"""
89
This class should provide you with all the basic vector operations that you need, but feel free to extend its
@@ -21,7 +22,7 @@ class Vec3:
2122
'z'
2223
]
2324

24-
def __init__(self, x: Union[float, 'Vec3']=0, y: float=0, z: float=0):
25+
def __init__(self, x: Union[float, 'Vec3', 'Vector3']=0, y: float=0, z: float=0):
2526
"""
2627
Create a new Vec3. The x component can alternatively be another vector with an x, y, and z component, in which
2728
case the created vector is a copy of the given vector and the y and z parameter is ignored. Examples:
@@ -74,23 +75,21 @@ def flat(self):
7475
"""Returns a new Vec3 that equals this Vec3 but projected onto the ground plane. I.e. where z=0."""
7576
return Vec3(self.x, self.y, 0)
7677

77-
@property
7878
def length(self):
7979
"""Returns the length of the vector. Also called magnitude and norm."""
8080
return math.sqrt(self.x**2 + self.y**2 + self.z**2)
8181

8282
def dist(self, other: 'Vec3') -> float:
8383
"""Returns the distance between this vector and another vector using pythagoras."""
84-
return (self - other).length
84+
return (self - other).length()
8585

86-
@property
8786
def normalized(self):
8887
"""Returns a vector with the same direction but a length of one."""
89-
return self / self.length
88+
return self / self.length()
9089

9190
def rescale(self, new_len: float) -> 'Vec3':
9291
"""Returns a vector with the same direction but a different length."""
93-
return new_len * self.normalized
92+
return new_len * self.normalized()
9493

9594
def dot(self, other: 'Vec3') -> float:
9695
"""Returns the dot product."""
@@ -106,5 +105,5 @@ def cross(self, other: 'Vec3') -> 'Vec3':
106105

107106
def ang_to(self, ideal: 'Vec3') -> float:
108107
"""Returns the angle to the ideal vector. Angle will be between 0 and pi."""
109-
cos_ang = self.dot(ideal) / (self.length * ideal.length)
108+
cos_ang = self.dot(ideal) / (self.length() * ideal.length())
110109
return math.acos(cos_ang)

0 commit comments

Comments
 (0)