Did I find the right examples for you? yes no

# MAVProxy.modules.lib.mp_util.gps_newpos

All Samples(26)  |  Call(26)  |  Derive(0)  |  Import(0)
```extrapolate latitude/longitude given a heading and distance
thanks to http://www.movable-type.co.uk/scripts/latlong.html
```

```        def gps_newpos(lat, lon, bearing, distance):
'''extrapolate latitude/longitude given a heading and distance
thanks to http://www.movable-type.co.uk/scripts/latlong.html
'''
lat1 = math.radians(lat)
lon1 = math.radians(lon)
brng = math.radians(bearing)
dr = distance/radius_of_earth

lat2 = math.asin(math.sin(lat1)*math.cos(dr) +
math.cos(lat1)*math.sin(dr)*math.cos(brng))
lon2 = lon1 + math.atan2(math.sin(brng)*math.sin(dr)*math.cos(lat1),
math.cos(dr)-math.sin(lat1)*math.sin(lat2))
return (math.degrees(lat2), wrap_valid_longitude(math.degrees(lon2)))
```

src/m/a/MAVProxy-1.3.3/MAVProxy/modules/mavproxy_map/mp_slipmap.py   MAVProxy(Download)
```
for i in range(count*2+2):
pos1 = mp_util.gps_newpos(start[0], start[1], 90, i*spacing)
pos3 = mp_util.gps_newpos(pos1[0], pos1[1], 0, 3*count*spacing)
self.draw_line(img, pixmapper, pos1, pos3, self.colour, self.linewidth)

pos1 = mp_util.gps_newpos(start[0], start[1], 0, i*spacing)
pos3 = mp_util.gps_newpos(pos1[0], pos1[1], 90, 3*count*spacing)
```
```        distance = mp_util.gps_distance(lat2, lon2, lat, lon)
bearing  = mp_util.gps_bearing(lat2, lon2, lat, lon)
(state.lat, state.lon) = mp_util.gps_newpos(state.lat, state.lon, bearing, distance)

def change_zoom(self, zoom):
```

src/m/a/MAVProxy-HEAD/MAVProxy/modules/mavproxy_map/mp_slipmap.py   MAVProxy(Download)
```
for i in range(count*2+2):
pos1 = mp_util.gps_newpos(start[0], start[1], 90, i*spacing)
pos3 = mp_util.gps_newpos(pos1[0], pos1[1], 0, 3*count*spacing)
self.draw_line(img, pixmapper, pos1, pos3, self.colour, self.linewidth)

pos1 = mp_util.gps_newpos(start[0], start[1], 0, i*spacing)
pos3 = mp_util.gps_newpos(pos1[0], pos1[1], 90, 3*count*spacing)
```
```        distance = mp_util.gps_distance(lat2, lon2, lat, lon)
bearing  = mp_util.gps_bearing(lat2, lon2, lat, lon)
(state.lat, state.lon) = mp_util.gps_newpos(state.lat, state.lon, bearing, distance)

def change_zoom(self, zoom):
```

src/m/a/MAVProxy-1.3.3/MAVProxy/modules/mavproxy_map/mp_tile.py   MAVProxy(Download)
```		pixel_width = ground_width / float(width)
ground_height = ground_width * (height/(float(width)))
top_right = mp_util.gps_newpos(lat, lon, 90, ground_width)
bottom_left = mp_util.gps_newpos(lat, lon, 180, ground_height)
bottom_right = mp_util.gps_newpos(bottom_left[0], bottom_left[1], 90, ground_width)
```

src/m/a/MAVProxy-HEAD/MAVProxy/modules/mavproxy_map/mp_tile.py   MAVProxy(Download)
```		pixel_width = ground_width / float(width)
ground_height = ground_width * (height/(float(width)))
top_right = mp_util.gps_newpos(lat, lon, 90, ground_width)
bottom_left = mp_util.gps_newpos(lat, lon, 180, ground_height)
bottom_right = mp_util.gps_newpos(bottom_left[0], bottom_left[1], 90, ground_width)
```

src/m/a/MAVProxy-1.3.3/MAVProxy/tools/mavflightview.py   MAVProxy(Download)
```    bounds = mp_util.polygon_bounds(path[0])
(lat, lon) = (bounds[0]+bounds[2], bounds[1])
(lat, lon) = mp_util.gps_newpos(lat, lon, -45, 50)
ground_width = mp_util.gps_distance(lat, lon, lat-bounds[2], lon+bounds[3])
while (mp_util.gps_distance(lat, lon, bounds[0], bounds[1]) >= ground_width-20 or
```

src/m/a/MAVProxy-HEAD/MAVProxy/tools/mavflightview.py   MAVProxy(Download)
```    bounds = mp_util.polygon_bounds(path[0])
(lat, lon) = (bounds[0]+bounds[2], bounds[1])
(lat, lon) = mp_util.gps_newpos(lat, lon, -45, 50)
ground_width = mp_util.gps_distance(lat, lon, lat-bounds[2], lon+bounds[3])
while (mp_util.gps_distance(lat, lon, bounds[0], bounds[1]) >= ground_width-20 or
```

src/m/a/MAVProxy-1.3.3/MAVProxy/modules/mavproxy_map/__init__.py   MAVProxy(Download)
```            if self.master.flightmode in [ "AUTO", "GUIDED", "LOITER", "RTL" ]:
trajectory = [ (self.lat, self.lon),
mp_util.gps_newpos(self.lat, self.lon, m.target_bearing, m.wp_dist) ]
self.mpstate.map.add_object(mp_slipmap.SlipPolygon('trajectory', trajectory, layer='Trajectory',
linewidth=2, colour=(255,0,180)))
```

src/m/a/MAVProxy-HEAD/MAVProxy/modules/mavproxy_map/__init__.py   MAVProxy(Download)
```            if self.master.flightmode in [ "AUTO", "GUIDED", "LOITER", "RTL" ]:
trajectory = [ (self.lat, self.lon),
mp_util.gps_newpos(self.lat, self.lon, m.target_bearing, m.wp_dist) ]
self.mpstate.map.add_object(mp_slipmap.SlipPolygon('trajectory', trajectory, layer='Trajectory',
linewidth=2, colour=(255,0,180)))
```

src/m/a/MAVProxy-1.3.3/MAVProxy/modules/mavproxy_cameraview.py   MAVProxy(Download)
```                # so it doesn't make sense to try to draw the polygon
return
gps_positions = [mp_util.gps_newpos(state.lat, state.lon, math.degrees(math.atan2(*pixel_position)), math.hypot(*pixel_position)) for pixel_position in pixel_positions]

# draw new polygon
```

src/m/a/MAVProxy-HEAD/MAVProxy/modules/mavproxy_cameraview.py   MAVProxy(Download)
```                # so it doesn't make sense to try to draw the polygon
return
gps_positions = [mp_util.gps_newpos(state.lat, state.lon, math.degrees(math.atan2(*pixel_position)), math.hypot(*pixel_position)) for pixel_position in pixel_positions]

# draw new polygon
```