New Reply

Velocity based on turning-angle

 
Share Thread Thread Tools
Sep29-11, 08:09 AM   #1
 

Velocity based on turning-angle


Hi! I'm new to the forum, so I'll present myself.
My name is Christoffer, I'm 24 years old, and i work as a programmer. I have an amatuerish interest in math an physics, and I'm not completely lost in the field of math.
I have however encountered a problem in a program I'm writing, and I'm stumped.
I am "simulating" (it's not really a simulation, it just needs to look good) a tank moving along a given path made up from points.
Each time I reach a new point in the path, I start turning to the next point while pushing the tank forward in the direction it's facing.
This all works fine, the problem is adjusting the tanks velocity, since some turns may be too sharp, and the tank may never reach the goal.

I calculate the movement like this:

Code:
to_next_path_point = next_path_point - position
dir_to_next = normalize(to_next_path_point)
dp = dot_product(dir_to_next, tank_forward)
angle = acos(dp)
rotation_this_update= tank_rotation_speed * delta_time
if angle < rotation_this_update 
   new_dir = dir_to_next
else
   t = rotation_this_update / angle 
   new_dir = vector_lerp(tank_forward, dir_to_next, t)
end

new_position = position + new_dir * velocity * delta_time
I realize that I may need some other defined variables in order to make this work, but I don't really know what.
I have to find out whether a given pathpoint is unreachable, and in that case decelerate.

Again, I'm not looking for the physically absolute correct way of calculating the turning radius, I'm just wondering if anyone has got a smart way of getting around this problem.

Thanks in advance
/ Christoffer

P.S Sorry if my english sucks :/
PhysOrg.com
PhysOrg
science news on PhysOrg.com

>> Bird's playlist could signal mental strengths and weaknesses
>> Minus environment, patterns still emerge: Computational study tracks E. coli cells' regulatory mechanisms
>> Bacterium uses natural 'thermometer' to trigger diarrheal disease, scientists find
New Reply
Thread Tools


Similar Threads for: Velocity based on turning-angle
Thread Forum Replies
length of a pendulum based on speed and max angle Introductory Physics Homework 10
Please set me straight about velocity based time travel Special & General Relativity 1
Calculate displacement based on velocity and acceleration Introductory Physics Homework 3
Velocity based frictional force equations Introductory Physics Homework 2