I have dataframe with measurements coordinates and cell coordinates.
I need to find for each row angle (azimuth angle) between a line that connects these two points and the north pole.
df:
id cell_lat cell_long meas_lat meas_long
1 53.543643 11.636235 53.44758 11.03720
2 52.988823 10.0421645 53.03501 9.04165
3 54.013442 9.100981 53.90384 10.62370
I have found some code online, but none if that really helps me get any closer to the solution.
I have used this function but not sure if get it right and I guess there is simplier solution.
Any help or hint is welcomed, thanks in advance.
The trickiest part of this problem is converting geodetic (latitude, longitude) coordinates to Cartesian (x, y, z) coordinates. If you look at https://en.wikipedia.org/wiki/Geographic_coordinate_conversion you can see how to do this, which involves choosing a reference system. Assuming we choose ECEF (https://en.wikipedia.org/wiki/ECEF), the following code calculates the angles you are looking for:
def vector_calc(lat, long, ht):
'''
Calculates the vector from a specified point on the Earth's surface to the North Pole.
'''
a = 6378137.0 # Equatorial radius of the Earth
b = 6356752.314245 # Polar radius of the Earth
e_squared = 1 - ((b ** 2) / (a ** 2)) # e is the eccentricity of the Earth
n_phi = a / (np.sqrt(1 - (e_squared * (np.sin(lat) ** 2))))
x = (n_phi + ht) * np.cos(lat) * np.cos(long)
y = (n_phi + ht) * np.cos(lat) * np.sin(long)
z = ((((b ** 2) / (a ** 2)) * n_phi) + ht) * np.sin(lat)
x_npole = 0.0
y_npole = 6378137.0
z_npole = 0.0
v = ((x_npole - x), (y_npole - y), (z_npole - z))
return v
def angle_calc(lat1, long1, lat2, long2, ht1=0, ht2=0):
'''
Calculates the angle between the vectors from 2 points to the North Pole.
'''
# Convert from degrees to radians
lat1_rad = (lat1 / 180) * np.pi
long1_rad = (long1 / 180) * np.pi
lat2_rad = (lat2 / 180) * np.pi
long2_rad = (long2 / 180) * np.pi
v1 = vector_calc(lat1_rad, long1_rad, ht1)
v2 = vector_calc(lat2_rad, long2_rad, ht2)
# The angle between two vectors, vect1 and vect2 is given by:
# arccos[vect1.vect2 / |vect1||vect2|]
dot = np.dot(v1, v2) # The dot product of the two vectors
v1_mag = np.linalg.norm(v1) # The magnitude of the vector v1
v2_mag = np.linalg.norm(v2) # The magnitude of the vector v2
theta_rad = np.arccos(dot / (v1_mag * v2_mag))
# Convert radians back to degrees
theta = (theta_rad / np.pi) * 180
return theta
angles = []
for row in range(df.shape[0]):
cell_lat = df.iloc[row]['cell_lat']
cell_long = df.iloc[row]['cell_long']
meas_lat = df.iloc[row]['meas_lat']
meas_long = df.iloc[row]['meas_long']
angle = angle_calc(cell_lat, cell_long, meas_lat, meas_long)
angles.append(angle)
This will read each row out of your dataframe, calculate the angle and append it to the list angles. Obviously you can do what you like with those angles after they've been calculated.
Hope that helps!
Related
Doing the Mars Rover coding problem and am stuck at level 2. Trying to debug but I just can't see it and it wont let me progress until current level is finished.
Problem Description as follows:
Calculate the position and the direction of the rover after driving a certain distance with a certain steering angle.
Input: WheelBase, Distance, SteeringAngle (2 decimal floats)
Output: X, Y, NewDirection Angle
Example:
In: 1.00 1.00 30.00
Out: 0.24 0.96 28.65
Anybody know of any links to some walk throughs, solutions etc or more examples?
There is an image link to the coding problem at the bottom
Thanks
https://catcoder.codingcontest.org/training/1212/play
## Level 1 - calculate the turn radius ##
## level1 2 - calculate new position and angle
import math
## solution works for this data
WHEELBASE = 1.00
DISTANCE = 1.00
STEERINGANGLE = 30.00
#WHEELBASE = 1.75
#DISTANCE = 3.14
#STEERINGANGLE = -23.00
def calculateTurnRadius(wheelbase, steeringangle):
return round(wheelbase / math.sin(math.radians(steeringangle)), 2)
def calculateNewDirection(wheelbase, steeringangle, distance):
turnRadius = calculateTurnRadius(wheelbase, steeringangle)
theta = distance / turnRadius
#brings theta to within a 180 arc
while theta >= math.pi * 2:
theta -= math.pi * 2
while theta < 0:
theta += math.pi * 2
# calculate theta with basic sin and cos trig
x = turnRadius - (math.cos(theta) * turnRadius)
y = math.sin(theta) * turnRadius
x = abs(round(x, 2))
y = round(y, 2)
theta = math.degrees(theta)
theta = round(theta, 2)
return x, y, theta
print(f"Turn Radius = {calculateTurnRadius(WHEELBASE, STEERINGANGLE)}")
print(f"{calculateNewDirection(WHEELBASE, STEERINGANGLE, DISTANCE)}")
Turn Radius = 2.0
(0.24, 0.96, 28.65)
[1]: https://i.stack.imgur.com/tDY2u.jpg
I'm also stuck, but what I have so far works for the first 2 inputs:
import math
WheelBase, Distance, SteeringAngle = 1, 1, 30.00
WheelBase, Distance, SteeringAngle = 2.13, 4.30, 23.00
WheelBase = float(WheelBase)
Distance = float(Distance)
SteeringAngle = float(SteeringAngle)
TurnRadius = abs(WheelBase / math.sin(math.pi * (SteeringAngle) / 180))
NewDirection = 180 * (Distance / TurnRadius) / math.pi
chord = 2 * TurnRadius * math.sin(math.pi * NewDirection / 360)
y = TurnRadius * math.sin(math.pi * (NewDirection) / 180)
x = math.sqrt(chord ** 2 - y ** 2)
print(round(x, 2), round(y, 2), round(NewDirection, 2))
print(chord)
print(math.sqrt(x ** 2 + y ** 2))
I haven't really looked at your code, but I got the solutions from level 1 to 4. So here's my code for level 2.
import math
def turn_radius(wheel_base, steering_angle):
radius: float = wheel_base/math.sin(math.radians(steering_angle))
print (f"{radius:.2f}")
return radius
def get_position(distance, steering_angle, radius):
angle = (distance*180)/(math.pi*radius)
y = (math.sin(math.radians(angle)) * radius)
x = radius - (math.cos(math.radians(angle)) * radius)
while angle < 0:
angle = 360 + angle
if angle == 360:
angle = 0
print(f"{x:.2f} {y:.2f} {angle:.2f}")
if __name__ == "__main__":
wheel_base = 2.7
distance = 45
steering_angle = -34
if steering_angle == 0:
steering_angle = 360
radius = turn_radius(wheel_base ,steering_angle)
get_position(distance, steering_angle, radius)
I have a set of 3D points and the correspondend point in 2D from a diffrent position.
The 2D points are on a 360° panorama. So i can convert them to polar -> (r,theta , phi ) with no information about r.
But r is just the distance of the transformed 3D Point:
[R|t]*xyz = xyz'
r = sqrt(xyz')
Then with the 3D point also in spherical coordinates, i can now search for R and t with this linear equation system:
x' = sin(theta) * cos(phi) * r
y' = sin(theta) * cos(phi) * r
z' = sin(theta) * cos(phi) * r
I get good results for tests with t=[0,0,0.5] and without any rotation. But if there is a rotation the results are bad.
Is this the correct approach for my problem?
How can I use solvepnp() without a camera Matrix (it is a panorama without distortion)?
I am using opt.least_squares to calculate R and t.
I solved it with two diffrent methods.
One is for small rotations and solves for R and t (12 parameter), the other method can compute even big rotations with Euler and t (6 parameter).
I am calling the opt.least_squares() two times with diffrent initial values and use the method with an better reprojection error.
The f.eul2rot is just a conversion between euler angles and the rotation matrix.
def sphere_eq(p):
xyz_points = xyz
uv_points = uv
#r11,r12,r13,r21,r22,r23,r31,r32,r33,tx,ty,tz = p
if len(p) == 12:
r11, r12, r13, r21, r22, r23, r31, r32, r33, tx, ty, tz = p
R = np.array([[r11, r12, r13],
[r21, r22, r23],
[r31, r32, r33]])
else:
gamma, beta, alpha,tx,ty,tz = p
E = [gamma, beta, alpha]
R = f.eul2rot(E)
pi = np.pi
eq_grad = ()
for i in range(len(xyz_points)):
# Point with Orgin: LASER in Cartesian and Spherical coordinates
xyz_laser = np.array([xyz_points[i,0],xyz_points[i,1],xyz_points[i,2]])
# Transformation - ROTATION MATRIX and Translation Vector
t = np.array([[tx, ty, tz]])
# Point with Orgin: CAMERA in Cartesian and Spherical coordinates
uv_camera = np.array(uv_points[i])
long_camera = ((uv_camera[0]) / w) * 2 * pi
lat_camera = ((uv_camera[1]) / h) * pi
xyz_camera = (R.dot(xyz_laser) + t)[0]
r = np.linalg.norm(xyz_laser + t)
x_eq = (xyz_camera[0] - (np.sin(lat_camera) * np.cos(long_camera) * r),)
y_eq = (xyz_camera[1] - (np.sin(lat_camera) * np.sin(long_camera) * r),)
z_eq = (xyz_camera[2] - (np.cos(lat_camera) * r),)
eq_grad = eq_grad + x_eq + y_eq + z_eq
return eq_grad
x = np.zeros(12)
x[0], x[4], x[8] = 1, 1, 1
initial_guess = [x,np.zeros(6)]
for p, x0 in enumerate(initial_guess):
x = opt.least_squares(sphere_eq, x0, '3-point', method='trf')
if len(x0) == 6:
E = np.resize(x.x[:4], 3)
R = f.eul2rot(E)
t = np.resize(x.x[4:], (3, 1))
else:
R = np.resize(x.x[:8], (3, 3))
E = f.rot2eul(R)
t = np.resize(x.x[9:], (3, 1))
I want to use Python/Matplotlib/Basemap to draw a map and shade a circle that lies within a given distance of a specified point, similar to this (Map generated by the Great Circle Mapper - copyright © Karl L. Swartz.):
I can get the map to generate as follows:
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# create new figure, axes instances.
fig,ax = plt.subplots()
# setup Mercator map projection.
m = Basemap(
llcrnrlat=47.0,
llcrnrlon=-126.62,
urcrnrlat=50.60,
urcrnrlon=-119.78,
rsphere=(6378137.00,6356752.3142),
resolution='i',
projection='merc',
lat_0=49.290,
lon_0=-123.117,
)
# Latitudes and longitudes of locations of interest
coords = dict()
coords['SEA'] = [47.450, -122.309]
# Plot markers and labels on map
for key in coords:
lon, lat = coords[key]
x,y = m(lat, lon)
m.plot(x, y, 'bo', markersize=5)
plt.text(x+10000, y+5000, key, color='k')
# Draw in coastlines
m.drawcoastlines()
m.fillcontinents()
m.fillcontinents(color='grey',lake_color='aqua')
m.drawmapboundary(fill_color='aqua')
plt.show()
which generates the map:
Now I would like to create a great circle around a specified point, such as the top map.
My attempt is a function that takes the map object, a center coordinate pair and a distance, and creates two curves and then shade between them, something like:
def shaded_great_circle(map_, lat_0, lon_0, dist=100, alpha=0.2): # dist specified in nautical miles
dist = dist * 1852 # Convert distance to nautical miles
lat = np.linspace(lat_0-dist/2, lat_0+dist/2,50)
lon = # Somehow find these points
# Create curve for longitudes above lon_0
# Create curve for longitudes below lon_0
# Shade region between above two curves
where I have commented what I want to do, but am not sure how to do it.
I have tried a few ways to do this, but what has me confused is that all inputs to the map are coordinates measured in degrees, whereas I want to specify points in length, and have that converted to latitude/longitude points to plot. I think this is related to data as lat/lon in degrees versus map projection coordinates.
Any nudges in the right direction would be appreciated
Thanks
In the end I had to implement this manually.
In short, I used an equation given here to calculate the coordinates given an
initial starting point and a radial to calculate points around 360 degrees, and then plot a line through these points. I don't really need the shading part, so I haven't implemented that yet.
I thought this is a useful feature so here is how I implemented it:
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
def calc_new_coord(lat1, lon1, rad, dist):
"""
Calculate coordinate pair given starting point, radial and distance
Method from: http://www.geomidpoint.com/destination/calculation.html
"""
flat = 298.257223563
a = 2 * 6378137.00
b = 2 * 6356752.3142
# Calculate the destination point using Vincenty's formula
f = 1 / flat
sb = np.sin(rad)
cb = np.cos(rad)
tu1 = (1 - f) * np.tan(lat1)
cu1 = 1 / np.sqrt((1 + tu1*tu1))
su1 = tu1 * cu1
s2 = np.arctan2(tu1, cb)
sa = cu1 * sb
csa = 1 - sa * sa
us = csa * (a * a - b * b) / (b * b)
A = 1 + us / 16384 * (4096 + us * (-768 + us * (320 - 175 * us)))
B = us / 1024 * (256 + us * (-128 + us * (74 - 47 * us)))
s1 = dist / (b * A)
s1p = 2 * np.pi
while (abs(s1 - s1p) > 1e-12):
cs1m = np.cos(2 * s2 + s1)
ss1 = np.sin(s1)
cs1 = np.cos(s1)
ds1 = B * ss1 * (cs1m + B / 4 * (cs1 * (- 1 + 2 * cs1m * cs1m) - B / 6 * \
cs1m * (- 3 + 4 * ss1 * ss1) * (-3 + 4 * cs1m * cs1m)))
s1p = s1
s1 = dist / (b * A) + ds1
t = su1 * ss1 - cu1 * cs1 * cb
lat2 = np.arctan2(su1 * cs1 + cu1 * ss1 * cb, (1 - f) * np.sqrt(sa * sa + t * t))
l2 = np.arctan2(ss1 * sb, cu1 * cs1 - su1 * ss1 * cb)
c = f / 16 * csa * (4 + f * (4 - 3 * csa))
l = l2 - (1 - c) * f * sa * (s1 + c * ss1 * (cs1m + c * cs1 * (-1 + 2 * cs1m * cs1m)))
d = np.arctan2(sa, -t)
finaltc = d + 2 * np.pi
backtc = d + np.pi
lon2 = lon1 + l
return (np.rad2deg(lat2), np.rad2deg(lon2))
def shaded_great_circle(m, lat_0, lon_0, dist=100, alpha=0.2, col='k'): # dist specified in nautical miles
dist = dist * 1852 # Convert distance to nautical miles
theta_arr = np.linspace(0, np.deg2rad(360), 100)
lat_0 = np.deg2rad(lat_0)
lon_0 = np.deg2rad(lon_0)
coords_new = []
for theta in theta_arr:
coords_new.append(calc_new_coord(lat_0, lon_0, theta, dist))
lat = [item[0] for item in coords_new]
lon = [item[1] for item in coords_new]
x, y = m(lon, lat)
m.plot(x, y, col)
# setup Mercator map projection.
m = Basemap(
llcrnrlat=45.0,
llcrnrlon=-126.62,
urcrnrlat=50.60,
urcrnrlon=-119.78,
rsphere=(6378137.00,6356752.3142),
resolution='i',
projection='merc',
lat_0=49.290,
lon_0=-123.117,
)
# Latitudes and longitudes of locations of interest
coords = dict()
coords['SEA'] = [47.450, -122.309]
# Plot markers and labels on map
for key in coords:
lon, lat = coords[key]
x,y = m(lat, lon)
m.plot(x, y, 'bo', markersize=5)
plt.text(x+10000, y+5000, key, color='k')
# Draw in coastlines
m.drawcoastlines()
m.fillcontinents()
m.fillcontinents(color='grey',lake_color='aqua')
m.drawmapboundary(fill_color='aqua')
# Draw great circle
shaded_great_circle(m, 47.450, -122.309, 100, col='k') # Distance specified in nautical miles, i.e. 100 nmi in this case
plt.show()
Running this should give you (with 100 nautical mile circle around Seattle):
I have the following data points: There are 5 sublists in this list of data. What I am trying to do is find the points where there is a maximum amount of curvature.
for i in range(len(smallest_5)):
x = [x for x,y in smallest_5[i]]
y = [y for x,y in smallest_5[i]]
plt.scatter(x,y)
plt.savefig('bend'+str(count)+'.png')
plt.show()
I've used this code to plot the points.
sub_curvature = []
for i in range(len(smallest_5)):
a = np.array(smallest_5[i])
dx_dt = np.gradient(a[:,0])
dy_dt = np.gradient(a[:,1])
velocity = np.array([ [dx_dt[i], dy_dt[i]] for i in range(dx_dt.size)])
ds_dt = np.sqrt(dx_dt * dx_dt + dy_dt * dy_dt)
tangent = np.array([1/ds_dt] * 2).transpose() * velocity
tangent_x = tangent[:, 0]
tangent_y = tangent[:, 1]
deriv_tangent_x = np.gradient(tangent_x)
deriv_tangent_y = np.gradient(tangent_y)
dT_dt = np.array([ [deriv_tangent_x[i], deriv_tangent_y[i]] for i in range(deriv_tangent_x.size)])
length_dT_dt = np.sqrt(deriv_tangent_x * deriv_tangent_x + deriv_tangent_y * deriv_tangent_y)
normal = np.array([1/length_dT_dt] * 2).transpose() * dT_dt
d2s_dt2 = np.gradient(ds_dt)
d2x_dt2 = np.gradient(dx_dt)
d2y_dt2 = np.gradient(dy_dt)
curvature = np.abs(d2x_dt2 * dy_dt - dx_dt * d2y_dt2) / (dx_dt * dx_dt + dy_dt * dy_dt)**1.5
t_component = np.array([d2s_dt2] * 2).transpose()
n_component = np.array([curvature * ds_dt * ds_dt] * 2).transpose()
acceleration = t_component * tangent + n_component * normal
sub_curvature.append(curvature)
I used the code above to calculate the curvature of individual points on the data.
Above are some of the graphs I created using the data. As you can see, the first one has no real bend but the last two have a point where there is a large bend. How could I go about identifying this region? Is it correct to calculate the curvature for individual points or should I look at the curvature over a sliding window of points? Thank you!
If we assume "curvature" to mean circular curvature, then you'll need a sliding window over 3 points (since 3 points determine a circle).
For any three points (a,b,c) the curvature is 2 * |(a-b) x (b-c)| / (|a-b| * |b-c| * |c-b|).
We can get a-b and b-c from
ab = smallest_5[1:] - smallest_5[:-1]
and a-c from:
ac = smallest_5[2:] - smallest_5[:-2]
Then the squared curvature is:
curv_sq = 4 * (np.cross(ab[1:], ab[:-1])**2).sum() / ((ab[1:]**2).sum() * (ab[:-1]**2).sum() * (ac**2).sum())
Since we're just looking for a maximum curvature, we don't actually have to take the square root of that. We can find the index of the point with maximum curvature with
max_curv_index = np.argmax(curv_sq)
As an idea, you can find the minimum y which is not the first or the last value in the y-dimension of the array. For example:
s4 = np.array(smallest_5[4]).T # exctract a sub-array
min_y = np.agrmin(s4[1]) # gives 13
min_y == (0 or len(s4[1]-1) # gives False, so the minimum is in the middle of the curve
s0 = np.array(smallest_5[0]).T # exctract a sub-array
min_y = np.agrmin(s0[1]) # gives 16
min_y == (0 or len(s0[1]-1) # gives True, so the minimum is not in the middle of the curve
I've been trying to rotate a bunch of lines by 90 degrees (that together form a polyline). Each line contains two vertices, say (x1, y1) and (x2, y2). What I'm currently trying to do is rotate around the center point of the line, given center points |x1 - x2| and |y1 - y2|. For some reason (I'm not very mathematically savvy) I can't get the lines to rotate correctly.
Could someone verify that the math here is correct? I'm thinking that it could be correct, however, when I set the line's vertices to the new rotated vertices, the next line may not be grabbing the new (x2, y2) vertex from the previous line, causing the lines to rotate incorrectly.
Here's what I've written:
def rotate_lines(self, deg=-90):
# Convert from degrees to radians
theta = math.radians(deg)
for pl in self.polylines:
self.curr_pl = pl
for line in pl.lines:
# Get the vertices of the line
# (px, py) = first vertex
# (ox, oy) = second vertex
px, ox = line.get_xdata()
py, oy = line.get_ydata()
# Get the center of the line
cx = math.fabs(px-ox)
cy = math.fabs(py-oy)
# Rotate line around center point
p1x = cx - ((px-cx) * math.cos(theta)) - ((py-cy) * math.sin(theta))
p1y = cy - ((px-cx) * math.sin(theta)) + ((py-cy) * math.cos(theta))
p2x = cx - ((ox-cx) * math.cos(theta)) - ((oy-cy) * math.sin(theta))
p2y = cy - ((ox-cx) * math.sin(theta)) + ((oy-cy) * math.cos(theta))
self.curr_pl.set_line(line, [p1x, p2x], [p1y, p2y])
The coordinates of the center point (cx,cy) of a line segment between points (x1,y1) and (x2,y2) are:
cx = (x1 + x2) / 2
cy = (y1 + y2) / 2
In other words it's just the average, or arithmetic mean, of the two pairs of x and y coordinate values.
For a multi-segmented line, or polyline, its logical center point's x and y coordinates are just the corresponding average of x and y values of all the points. An average is just the sum of the values divided by the number of them.
The general formulas to rotate a 2D point (x,y) θ radians around the origin (0,0) are:
x′ = x * cos(θ) - y * sin(θ)
y′ = x * sin(θ) + y * cos(θ)
To perform a rotation about a different center (cx, cy), the x and y values of the point need to be adjusted by first subtracting the coordinate of the desired center of rotation from the point's coordinate, which has the effect of moving (known in geometry as translating) it is expressed mathematically like this:
tx = x - cx
ty = y - cy
then rotating this intermediate point by the angle desired, and finally adding the x and y values of the point of rotation back to the x and y of each coordinate. In geometric terms, it's the following sequence of operations: Tʀᴀɴsʟᴀᴛᴇ ─► Rᴏᴛᴀᴛᴇ ─► Uɴᴛʀᴀɴsʟᴀᴛᴇ.
This concept can be extended to allow rotating a whole polyline about any arbitrary point—such as its own logical center—by just applying the math described to each point of each line segment within it.
To simplify implementation of this computation, the numerical result of all three sets of calculations can be combined and expressed with a pair of mathematical formulas which perform them all simultaneously. So a new point (x′,y′) can be obtained by rotating an existing point (x,y), θ radians around the point (cx, cy) by using:
x′ = ( (x - cx) * cos(θ) + (y - cy) * sin(θ) ) + cx
y′ = ( -(x - cx) * sin(θ) + (y - cy) * cos(θ) ) + cy
Incorporating this mathematical/geometrical concept into your function produces the following:
from math import sin, cos, radians
def rotate_lines(self, deg=-90):
""" Rotate self.polylines the given angle about their centers. """
theta = radians(deg) # Convert angle from degrees to radians
cosang, sinang = cos(theta), sin(theta)
for pl in self.polylines:
# Find logical center (avg x and avg y) of entire polyline
n = len(pl.lines)*2 # Total number of points in polyline
cx = sum(sum(line.get_xdata()) for line in pl.lines) / n
cy = sum(sum(line.get_ydata()) for line in pl.lines) / n
for line in pl.lines:
# Retrieve vertices of the line
x1, x2 = line.get_xdata()
y1, y2 = line.get_ydata()
# Rotate each around whole polyline's center point
tx1, ty1 = x1-cx, y1-cy
p1x = ( tx1*cosang + ty1*sinang) + cx
p1y = (-tx1*sinang + ty1*cosang) + cy
tx2, ty2 = x2-cx, y2-cy
p2x = ( tx2*cosang + ty2*sinang) + cx
p2y = (-tx2*sinang + ty2*cosang) + cy
# Replace vertices with updated values
pl.set_line(line, [p1x, p2x], [p1y, p2y])
Your center point is going to be:
centerX = (x2 - x1) / 2 + x1
centerY = (y2 - y1) / 2 + y1
because you take half the length (x2 - x1) / 2 and add it to where your line starts to get to the middle.
As an exercise, take two lines:
line1 = (0, 0) -> (5, 5)
then: |x1 - x2| = 5, when the center x value is at 2.5.
line2 = (2, 2) -> (7, 7)
then: |x1 - x2| = 5, which can't be right because that's the center for
the line that's parallel to it but shifted downwards and to the left