SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SH5 Mods Workshop
Forget password? Reset here

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 09-20-10, 06:58 PM   #11
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,959
Downloads: 147
Uploads: 5


Default

ran into a little problem with Automation's Navigate from file. Problem deals with calculating an offset heading to add to the sub's current heading so that the sub will head to the current/new waypoint. The waypoints are stored in a file as x,y meters from game origin (I added a new order to the nav officer's order bar that will show the sub's current position in the messagebox so that one can 'plot' a pattern/navigation). The code gets the sub's current fix as x,y meters from game origin. It then calculates the distance between the sub's fix and the current waypoint. That part is fine - distance shows perfect. The problem is this offset heading. When the sub is < 250m from the waypoint or when the half distance to the waypoint is reached it's supposed to calculate the offset to add to the current heading to keep it heading to the current/new waypoint. Something is wrong with my math and I'm not sure what it is. What would the formula be for calculating this offset given sub's current heading, current fix (x,y) and current waypoint (x,y)?? Using trig I tried using offset = atan2( fix.X - waypoint.X / fix.Y - waypoint.Y ) and adding this offset to the sub's current heading. Everything works fine as long as the waypoint is north of the sub. Any waypoints to the west or east are screwed up
TheDarkWraith is offline   Reply With Quote
 

Tags
dbrn, favorite, new ui


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 03:01 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Copyright © 1995- 2026 Subsim®
"Subsim" is a registered trademark, all rights reserved.