![]() |
SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997 |
|
|
12-18-10, 09:51 AM
|
#1 |
|
Lieutenant
![]() Join Date: Nov 2006
Location: St. Petersburg, Russia
Posts: 264
Downloads: 73
Uploads: 0
|
BTW, forgot to mention - there is another division by zero issue - if the tracking angle is 0 or 180 then sine of it is zero as well.
In the cases of zero divisions we need to use torpedo speed and that returns us to the problems with torpedo run away and turn times. |
|
|
12-18-10, 09:55 AM
|
#2 | |
|
Black Magic
![]() |
Quote:
![]() Here's the code I have for it: Code:
# get the target's speed ts = Menu.GuiDials.GetValue( GuiDialsWrapper.DialTypes.SOL_SPEED ) if ts == 0: ts = 0.000001 # get the distance to target td = Menu.GuiDials.GetValue( GuiDialsWrapper.DialTypes.SOL_RANGE ) # get the target's AOB from the TDC dial taob = abs( Menu.GuiDials.GetValue( GuiDialsWrapper.DialTypes.SOL_ANGONBOW ) ) # get the track angle tangle = abs( Menu.GuiDials.GetValue( GuiDialsWrapper.DialTypes.SOL_TRACKANGLE ) ) # calculate 3rd angle of triangle auxangle = radians( 180 - taob - ( 180 - tangle ) ) s_ship = td * ( sin( auxangle ) / sin( radians( 180 - tangle ) ) ) s_torp = td * ( sin( radians( taob ) ) / sin( radians( 180 - tangle ) ) ) #to hit torp.time = ship.time impacttime = int( round( s_ship / ts ) ) impacttimemins = impacttime / 60 impacttimesecs = impacttime - ( impacttimemins * 60 ) ![]() Using the TDW_Torp_Tutorial single mission when I set up the shot the torp line says ~2:33 to impact and the caculated values above say 0:35 |
|
|
|
12-18-10, 10:15 AM
|
#3 | ||
|
Grey Wolf
![]() Join Date: Feb 2009
Posts: 995
Downloads: 91
Uploads: 0
|
Quote:
But you can use to check the torpedo time: s.ship/v.ship = s.torpedo/v.torpedo Quote:
Why do you use ts=0 => ts = 0.000001 ? I wrote that if the v=0 these calculations have no sense and at this conditions t.torp = dist/v.torp What about missing source to 5.7.0 at first post?
__________________
![]() |
||
|
|
12-18-10, 10:35 AM
|
#4 | |
|
Black Magic
![]() |
Quote:
![]() I'd like to include this estimated impact time in v5.7.1 also. I use ts = 0.0000001 just to avoid the division by 0 for now. |
|
|
|
12-19-10, 07:28 AM
|
#5 | |
|
Lieutenant
![]() Join Date: Nov 2006
Location: St. Petersburg, Russia
Posts: 264
Downloads: 73
Uploads: 0
|
Quote:
Another thing: impacttimemins is int or float/double? If float - then you will always get zero seconds. |
|
|
|
12-19-10, 08:33 AM
|
#6 | |
|
Black Magic
![]() |
Quote:
|
|
|
|
![]() |
| Tags |
| dbrn, favorite, new ui |
| Thread Tools | |
| Display Modes | |
|
|
