Skip to content

Commit

Permalink
Fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ultrainstinct30 committed Jun 26, 2019
2 parents 9a58288 + a26583f commit 6648d43
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion role/_GoToPoint_.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
def init(_kub,target,theta):
global kub,GOAL_POINT,rotate,FLAG_turn,FLAG_move,FIRST_CALL
kub = _kub
GOAL_POINT = point_2d()
GOAL_POINT = Vector2D()
rotate = theta
GOAL_POINT.x = target.x
GOAL_POINT.y = target.y
Expand Down
23 changes: 12 additions & 11 deletions utils/math_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def intersection_with_line(self, line2):
try:
P.x = (c2 - c1) / (m1 - m2)
P.y = (m1 * c2 - m2 * c1) / (m1 - m2)
return P
except:
return None
return P
Expand Down Expand Up @@ -166,7 +167,13 @@ def normalized_vector(self):
# angle = math.atan(self.slope)
angle = self.angle
return Vector2D(math.cos(angle), math.sin(angle))


def nearest_point_on_line(self,point):
t=(point.y-self.point.y)*math.sin(self.angle)+(point.x-self.point.x)*(math.cos(self.angle))
x1=self.point.x+math.cos(self.angle)*t
y1=self.point.y+math.sin(self.angle)*t
point=Vector2D(x1,y1)
return point

##
## @var slope
Expand Down Expand Up @@ -205,9 +212,9 @@ def direction(vector):
return math.atan2(vector.y, vector.x)


def getPointBehindTheBall(point, theta):
x = point.x + (3.5 * BOT_RADIUS) * (math.cos(theta))
y = point.y + (3.5 * BOT_RADIUS) * (math.sin(theta))
def getPointBehindTheBall(point, theta, factor=3.5):
x = point.x + (factor * BOT_RADIUS) * (math.cos(theta))
y = point.y + (factor * BOT_RADIUS) * (math.sin(theta))
return Vector2D(int(x), int(y))

def getPointToGo(point, theta):
Expand Down Expand Up @@ -238,12 +245,6 @@ def stan_inverse(self,y,x):
else:
return atan2(y,x)+3.14159265


# def getPointBehindTheBall(point ,theta):
# x = point.x +(3.5 * BOT_RADIUS) *(math.cos(theta))
# y = point.y +(3.5 * BOT_RADIUS) *(math.sin(theta))
# return Vector2D(int(x), int(y))

def vicinity_points(point1, point2, thresh=10):
return dist(point1, point2) < thresh

Expand Down Expand Up @@ -289,4 +290,4 @@ def kub_has_ball(state, kub_id):
theta2 = math.atan2(state.ballPos.y - state.homePos[kub_id].y,
state.ballPos.x - state.homePos[kub_id].x)
return vicinity_theta(theta1, theta2, thresh=0.25) and vicinity_points(state.homePos[kub_id],
state.ballPos, thresh=BOT_RADIUS * 1.5)
state.ballPos, thresh=BOT_RADIUS * 1.5)
6 changes: 3 additions & 3 deletions utils/state_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def ball_moving_towards_our_goal(state):
ptA = Vector2D(-HALF_FIELD_MAXX, DBOX_HEIGHT)
ptB = Vector2D(-HALF_FIELD_MAXX, -DBOX_HEIGHT)
defend_line = Line(point1=ptA,point2=ptB)
opponent_aim = Line.intersection_with_line(ball_movement)
opponent_aim = defend_line.intersection_with_line(ball_movement)
if opponent_aim.y > -DBOX_HEIGHT and opponent_aim.y < DBOX_HEIGHT:
return True
return False
Expand Down Expand Up @@ -84,7 +84,7 @@ def closest_opponent(state, position):
def our_bot_closest_to_ball(state):
distance_from_ball = 99999999
our_bot_closest_to_ball = 0
for i in range(state.homePos.size()):
for i in range(len(state.homePos)):
dist = math.sqrt(pow((state.homePos[i].x - state.ballPos.x),2) + pow((state.homePos[i].y - state.ballPos.y) , 2))
if dist < distance_from_ball :
distance_from_ball = dist
Expand All @@ -95,7 +95,7 @@ def our_bot_closest_to_ball(state):
def opp_bot_closest_to_ball(state):
distance_from_ball = 99999999
opp_bot_closest_to_ball = 0
for i in range(state.awayPos.size()):
for i in range(len(state.awayPos)):
dist = math.sqrt(pow((state.awayPos[i].x - state.ballPos.x),2) + pow((state.awayPos[i].y - state.ballPos.y) , 2))
if dist < distance_from_ball :
distance_from_ball = dist
Expand Down

0 comments on commit 6648d43

Please sign in to comment.