I’m working on a 3D visualization project where I need to calculate a position of a point on ball.
I have 2 vectors:
-
Normalized direction vector[x,z]: which tells us which hemisphere we will hit(where the ball will go) only in the x and z axis.
-
Normalized face vector: what point in given hemisphere we want to know the position of (the 2d vector is a circle).
If we are given the radius of the ball and these 2 vectors, I want to calculate the point on the hemisphere opposite to the direction.
my idea is to first select the hemisphere opposite to the direction vector, then take that and calculate the point based on the face vector, but im not sure how to add the circumfrence to the equation.
I have thought of creating one big normalized 3d vector using these 2 vectors, then multiplying that vector with the radius, which gives us the point, but I cant prove this right.
how do we calculate the position of that point?
here is my attempts at it which all failed:
My first attempt returns the points from inside of the ball:
def calculate_impulse_point(direction, face, spin, radius, ball_position):
impulse_direction = np.array([direction[0], 0.0, direction[1]])
translated_distance_from_center = face[0] * impulse_direction
spin_vector = np.array([
translated_distance_from_center[2],
face[1],
translated_distance_from_center[0]
]) * spin
world_point = ball_position + spin_vector * radius
return world_point
my second attempt, which does not cover the entire hemisphere
def calculate_hit_point(direction, face, ball_radius=1.0):
direction = np.array([direction[0], direction[1], 0])
direction = direction / np.linalg.norm(direction)
back_point = -direction * ball_radius
spin_vector = np.array([-direction[1], direction[0], 0])
hit_point = back_point + spin_vector * face[0] * ball_radius
hit_point[2] = face[1] * ball_radius
hit_point = hit_point / np.linalg.norm(hit_point) * ball_radius
return hit_point
I tried to generate every possible face vector points using matplotlib, while fixing the direction, so i can visualize it, but i failed since the points should cover the entire hemisphere.
Thank you all!
here is the visualization
Fiddy Granger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.