SUBSIM Radio Room Forums

SUBSIM Radio Room Forums (https://www.subsim.com/radioroom/index.php)
-   SH4 Mods Workshop (https://www.subsim.com/radioroom/forumdisplay.php?f=219)
-   -   Zig Zags [TEC] [WIP] (https://www.subsim.com/radioroom/showthread.php?t=127809)

Peto 12-31-07 12:15 PM

Agree completely. The single column formations work fairly well with about 3 ships. If you use 4 I recommend closer spacing (~500-700 yards). That makes it easier for them to maintain theire location--not so far to go. It's also more accurate from a historical perspective.

Japanese convoys were notorious for poor station keeping though so if merchants romp around a little it's not a big deal IMHO.

tater 01-13-08 03:18 PM

Some code to play with (ACE version 0.4)

These are scripts (py files open as text).

Here is a sample of the code for ZZ pattern E:
Code:

def nm2meters(coords):
    res = []
    for c in coords:
        res.append((c[0]*1852, c[1]*1852))
    return res

def rotate(coords, heading):
    res = []
    angle = -heading*pi/180
    for c in coords:
        x = c[0] * cos(angle) - c[1] * sin (angle)
        y = c[0] * sin(angle) + c[1] * cos (angle)
        res.append((int (x), int (y)))
    return res
   
def coordsToWP(group,coords):
    for c in coords:
        wp = Waypoint(c[0]+group.longitude, c[1]+group.latitude, group.getWaypoints())
        group.getWaypoints().add(wp)

def heading2rad(heading):
    return  (pi/180)*((360+90-heading) % 360)

def projectPoint(base,speed,heading,minutes):
    angle = heading2rad(heading)
    distance = speed * minutes / 60
    x = base[0] + distance * cos(angle)
    y = base[1] + distance * sin(angle)
    return (x,y)

def zigZagA(speed):
    res = []
    res.append((0,0)) # Added for consistency, removed later
    res.append(projectPoint(res[-1],speed,60,5))
    res.append(projectPoint(res[-1],speed,30,5))   
    res.append(projectPoint(res[-1],speed,0,5))
    res.append(projectPoint(res[-1],speed,-30,5))
    res.append(projectPoint(res[-1],speed,-60,5))
    res.append(projectPoint(res[-1],speed,0,5))
    res.append(projectPoint(res[-1],speed,-60,5))
    res.append(projectPoint(res[-1],speed,-30,5))
    res.append(projectPoint(res[-1],speed,0,5))
    res.append(projectPoint(res[-1],speed,30,5))
    res.append(projectPoint(res[-1],speed,60,5))
    res.append(projectPoint(res[-1],speed,0,5))
    res.pop(0) # Remove first element (base)
    return nm2meters(res)

def patternLength(pattern):
    return sqrt(pattern[-1][0]*pattern[-1][0]+pattern[-1][1]*pattern[-1][1])

def patternSteps(waypoint,pattern):
    return int(waypoint.length/patternLength(pattern))

def patternToWaypoint(waypoint,iterator,pattern):
    last = waypoint.previous
    for x in range(0,patternSteps(waypoint, pattern)-1):
        wp = None
        for c in pattern:
            wp = Waypoint(c[0]+last.longitude, c[1]+last.latitude, group.getWaypoints())
            insertWaypointBeforeCursor(iterator,wp)
        last = wp

def zigZagWithPattern(group):
    i = group.waypoints.iterator ()
    for waypoint in i:
        patternToWaypoint(waypoint,i,rotate(zigZagA(waypoint.speed),waypoint.heading))

i = mission.randomGroups.iterator ()
for group in i:
    zigZagWithPattern(group)

This code within: defzigZagA(speed) is the pattern from the illustrations above. Speed, angle off base heading, and time on each leg. You can enter the angle and times right off the real japanese ZZ pattern diagram.

http://mpgtext.net/subshare/306ZigZags.rar

^^^^ my patterns so far.

Any with trailing lower case (ZZ_Pattern_Ab.py, for example) are non-historical variants created by increasing leg times in order to spread out the pattern more to save waypoints and to give ships more time to reform after a turn.

tater


All times are GMT -5. The time now is 11:02 AM.

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