module Geometry.Processes.Geodesics (geodesicEquation) where
import Geometry.Core
geodesicEquation
:: (Double -> Vec2 -> Double)
-> Double
-> (Vec2, Vec2)
-> (Vec2, Vec2)
geodesicEquation :: (Double -> Vec2 -> Double)
-> Double -> (Vec2, Vec2) -> (Vec2, Vec2)
geodesicEquation Double -> Vec2 -> Double
f Double
t (Vec2
v, v' :: Vec2
v'@(Vec2 Double
x' Double
y')) =
( Vec2
v'
, Double -> Double -> Vec2
Vec2
(-Dim -> Dim -> Double
c'x__V Dim
X Dim
XDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
x'Double -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2 Double -> Double -> Double
forall a. Num a => a -> a -> a
-Double
2Double -> Double -> Double
forall a. Num a => a -> a -> a
*Dim -> Dim -> Double
c'x__V Dim
X Dim
YDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
x'Double -> Double -> Double
forall a. Num a => a -> a -> a
*Double
y' Double -> Double -> Double
forall a. Num a => a -> a -> a
-Dim -> Dim -> Double
c'x__V Dim
Y Dim
YDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
y'Double -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2)
(-Dim -> Dim -> Double
c'y__V Dim
X Dim
XDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
x'Double -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2 Double -> Double -> Double
forall a. Num a => a -> a -> a
-Double
2Double -> Double -> Double
forall a. Num a => a -> a -> a
*Dim -> Dim -> Double
c'y__V Dim
X Dim
YDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
x'Double -> Double -> Double
forall a. Num a => a -> a -> a
*Double
y' Double -> Double -> Double
forall a. Num a => a -> a -> a
-Dim -> Dim -> Double
c'y__V Dim
Y Dim
YDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
y'Double -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2)
)
where
h :: Double
h = Double
1e-3
vXH :: Vec2
vXH = Vec2
v Vec2 -> Vec2 -> Vec2
forall v. VectorSpace v => v -> v -> v
+. Double -> Double -> Vec2
Vec2 Double
h Double
0
vYH :: Vec2
vYH = Vec2
v Vec2 -> Vec2 -> Vec2
forall v. VectorSpace v => v -> v -> v
+. Double -> Double -> Vec2
Vec2 Double
0 Double
h
vXHXH :: Vec2
vXHXH = Vec2
vXH Vec2 -> Vec2 -> Vec2
forall v. VectorSpace v => v -> v -> v
+. Double -> Double -> Vec2
Vec2 Double
h Double
0
vXHYH :: Vec2
vXHYH = Vec2
vYH Vec2 -> Vec2 -> Vec2
forall v. VectorSpace v => v -> v -> v
+. Double -> Double -> Vec2
Vec2 Double
h Double
0
vYHYH :: Vec2
vYHYH = Vec2
vYH Vec2 -> Vec2 -> Vec2
forall v. VectorSpace v => v -> v -> v
+. Double -> Double -> Vec2
Vec2 Double
0 Double
h
ftv :: Double
ftv = Double -> Vec2 -> Double
f Double
t Vec2
v
ftvXH :: Double
ftvXH = Double -> Vec2 -> Double
f Double
t Vec2
vXH
ftvYH :: Double
ftvYH = Double -> Vec2 -> Double
f Double
t Vec2
vYH
ftvXHYH :: Double
ftvXHYH = Double -> Vec2 -> Double
f Double
t Vec2
vXHYH
fdxvXH :: Double
fdxvXH = (Double -> Vec2 -> Double
f Double
t Vec2
vXHXH Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. Double
ftvXH) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
fdxvYH :: Double
fdxvYH = (Double
ftvXHYH Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. Double
ftvYH) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
fdyvXH :: Double
fdyvXH = (Double
ftvXHYH Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. Double
ftvXH) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
fdyvYH :: Double
fdyvYH = (Double -> Vec2 -> Double
f Double
t Vec2
vYHYH Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. Double
ftvYH) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
fdxV :: Double
fdxV = (Double
ftvXH Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. Double
ftv) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
fdyV :: Double
fdyV = (Double
ftvYH Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. Double
ftv) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
(Double
g'x'x, Double
g'x'y, Double
g'y'x, Double
g'y'y) =
let denominator :: Double
denominator = (Double
1Double -> Double -> Double
forall a. Num a => a -> a -> a
+Double
fdxVDouble -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2Double -> Double -> Double
forall a. Num a => a -> a -> a
+Double
fdyVDouble -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2)
in ( (Double
1Double -> Double -> Double
forall a. Num a => a -> a -> a
+Double
fdyVDouble -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2) Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/Double
denominator
, -(Double
fdxVDouble -> Double -> Double
forall a. Num a => a -> a -> a
*Double
fdyV) Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/Double
denominator
, Double
g'x'y
, (Double
1Double -> Double -> Double
forall a. Num a => a -> a -> a
+Double
fdxVDouble -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2) Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/Double
denominator
)
g__d_V :: Dim -> Dim -> Dim -> Double
g__d_V Dim
X Dim
X Dim
X = Double
g_x_xd_xV
g__d_V Dim
X Dim
X Dim
Y = Double
g_x_xd_yV
g__d_V Dim
X Dim
Y Dim
X = Double
g_x_yd_xV
g__d_V Dim
X Dim
Y Dim
Y = Double
g_x_yd_yV
g__d_V Dim
Y Dim
X Dim
X = Double
g_y_xd_xV
g__d_V Dim
Y Dim
X Dim
Y = Double
g_y_xd_yV
g__d_V Dim
Y Dim
Y Dim
X = Double
g_y_yd_xV
g__d_V Dim
Y Dim
Y Dim
Y = Double
g_y_yd_yV
g_x_xd_xV :: Double
g_x_xd_xV = ((Double
1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
fdxvXHDouble -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2) Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. (Double
1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
fdxVDouble -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2)) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
g_x_xd_yV :: Double
g_x_xd_yV = ((Double
1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
fdxvYHDouble -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2) Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. (Double
1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
fdxVDouble -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2)) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
g_x_yd_xV :: Double
g_x_yd_xV = ((Double
fdxvXH Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
fdyvXH) Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. (Double
fdxV Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
fdyV)) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
g_x_yd_yV :: Double
g_x_yd_yV = ((Double
fdxvYH Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
fdyvYH) Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. (Double
fdxV Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
fdyV)) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
g_y_xd_xV :: Double
g_y_xd_xV = ((Double
fdxvXH Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
fdyvXH) Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. (Double
fdxV Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
fdyV)) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
g_y_xd_yV :: Double
g_y_xd_yV = ((Double
fdxvYH Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
fdyvYH) Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. (Double
fdxV Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
fdyV)) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
g_y_yd_xV :: Double
g_y_yd_xV = ((Double
1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
fdyvXHDouble -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2) Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. (Double
1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
fdyVDouble -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2)) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
g_y_yd_yV :: Double
g_y_yd_yV = ((Double
1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
fdyvYHDouble -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2) Double -> Double -> Double
forall v. VectorSpace v => v -> v -> v
-. (Double
1 Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
fdyVDouble -> Integer -> Double
forall a b. (Num a, Integral b) => a -> b -> a
^Integer
2)) Double -> Double -> Double
forall v. VectorSpace v => v -> Double -> v
/. Double
h
c'x__V :: Dim -> Dim -> Double
c'x__V Dim
k Dim
l = Double
0.5 Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
g'x'x Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Dim -> Dim -> Dim -> Double
g__d_V Dim
X Dim
k Dim
l Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Dim -> Dim -> Dim -> Double
g__d_V Dim
X Dim
l Dim
k Double -> Double -> Double
forall a. Num a => a -> a -> a
- Dim -> Dim -> Dim -> Double
g__d_V Dim
k Dim
l Dim
X) Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
g'x'y Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Dim -> Dim -> Dim -> Double
g__d_V Dim
Y Dim
k Dim
l Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Dim -> Dim -> Dim -> Double
g__d_V Dim
Y Dim
l Dim
k Double -> Double -> Double
forall a. Num a => a -> a -> a
- Dim -> Dim -> Dim -> Double
g__d_V Dim
k Dim
l Dim
Y))
c'y__V :: Dim -> Dim -> Double
c'y__V Dim
k Dim
l = Double
0.5 Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Double
g'y'x Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Dim -> Dim -> Dim -> Double
g__d_V Dim
X Dim
k Dim
l Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Dim -> Dim -> Dim -> Double
g__d_V Dim
X Dim
l Dim
k Double -> Double -> Double
forall a. Num a => a -> a -> a
- Dim -> Dim -> Dim -> Double
g__d_V Dim
k Dim
l Dim
X) Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
g'y'y Double -> Double -> Double
forall a. Num a => a -> a -> a
* (Dim -> Dim -> Dim -> Double
g__d_V Dim
Y Dim
k Dim
l Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Dim -> Dim -> Dim -> Double
g__d_V Dim
Y Dim
l Dim
k Double -> Double -> Double
forall a. Num a => a -> a -> a
- Dim -> Dim -> Dim -> Double
g__d_V Dim
k Dim
l Dim
Y))
data Dim = X | Y