summaryrefslogtreecommitdiff
path: root/docs/pivot.txt
diff options
context:
space:
mode:
Diffstat (limited to 'docs/pivot.txt')
-rw-r--r--docs/pivot.txt146
1 files changed, 146 insertions, 0 deletions
diff --git a/docs/pivot.txt b/docs/pivot.txt
new file mode 100644
index 0000000..b945dd6
--- /dev/null
+++ b/docs/pivot.txt
@@ -0,0 +1,146 @@
1The pivot, p, is defined as the point, within the convex hull of the
2contacts, which, after rotation and scaling, leaves the transformed
3contacts as close to the actual positions as possible.
4
5Let r_i be the starting points and s_i the actual ending points in a
6transformation. Let D be the scaling, and R the rotation. Then, minimizing
7
8L(p) = sum_i |D R (r_i - p) + p - s_i|^2 / N
9
10yields the pivot. Let
11
12rm = sum_i r_i / N,
13p = rm + u,
14q_i = s_i - rm - D R (r_i - rm),
15
16and we get
17
18L(p) = sum_i |(1 - D R) u - q_i|^2 / N.
19
20With
21
22L0 = sum_i norm2(q_i) / N,
23T = (1 - D R)' (1 - D R),
24m = sum_i q_i / N,
25
26we can write this as
27
28L(p) = L0 + u' T u - 2 m' (1 - D R) u.
29
30To handle the constraint, we can approximate the hull with a circle
31centered at rm. If we pick the average radius, P, the constraint becomes
32
33|u| < P.
34
35Relaxing [1] the expression (h >= 0) yields
36
37L(p, h) = L0 + u' T u - 2 m' (1 - D R) u + h (|u|^2 - P^2),
38
39leading to the linear equation
40
41(T + h) u = (1 - D R)' m.
42
43Further,
44
45sm = sum_i s_i / N,
46m = sum_i (s_i - rm - D R (r_i - rm)) / N = sm - rm,
47
48thus m is the average displacement. In words, the pivot is the average
49position plus a correction depending on the average displacement.
50
51*
52
53Some algebra solves the equation,
54
55D' = D,
56[D, R] = 0,
57R = S + C,
58S' = -S,
59C' = C,
60R + R' = 2 C,
61T = (1 - D R)' (1 - D R) = 1 + D^2 - 2 D C,
62
63which is a simple diagonal scaling operator. With
64
65a = 1 - D C,
66b = D S,
67
68we can write this as
69
70T = (1 - DC)^2 + D^2(1 - C^2) = (1 - DC)^2 + D^2 S^2 = a^2 + b^2.
71
72Similarly, we can write
73
74(1 - D R)' = ((a, b), (-b, a)),
75
76and thusly,
77
78u = Q(h) m,
79
80with
81
82Q(h) = ((a, b), (-b, a)) / (a^2 + b^2 + h).
83
84When D R = 1, it follows that a^2 + b^2 = 0, and the relaxation ensures
85that u is finite.
86
87*
88
89The drag is found by minimizing
90
91E(d) = sum_i | D R (r_i - p) + p + d - s_i |^2 / N,
92E(d) = d^2 + 2 d' ((1 - D R) u - m) + E0,
93
94which leads to the linear equation
95
96d = m - (1 - D R) u.
97
98Explicitly,
99
100d = m - (a ux - b uy, a uy + b ux).
101
102Inserting the expression for u yields, after some algebra,
103
104d = m (1 - (a^2 + b^2) / (a^2 + b^2 + h)).
105
106When h = 0, d = 0, as expected.
107
108When a^2 + b^2 = 0, d = m, also as expected.
109
110For constrained cases, the drag is a fraction of the average displacement.
111
112*
113
114Time to look at measures for the relaxation parameter. Since d depends on
115h, we can write the correction u(h) in terms of d instead. After som
116algebra,
117
118|u(h)| = (|m| - |d|) / sqrt(a^2 + b^2).
119
120Conversely, d(h) can be written in terms of the constrained u(h) as
121
122d(h) = m (1 - sqrt(a^2 + b^2) |u(h)| / |m|).
123
124Since |u(0)| = |m| / sqrt(a^2 + b^2), we obtain
125
126d(h) = m (1 - |u(h)| / |u(0)|).
127
128*
129
130We can now write down an explicit recipe for determining the pivot (p) and
131drag (d), given the transformation parameters a and b.
132
133w = (a mx + b my, a my - b mx).
134
135If |w| = 0, then u = 0. Consequently p = rm, d = m, and we are done. Else,
136
137u = w |m|^2 / |w|^2,
138
139t = P / |u|.
140
141If t >= 1, then p = rm + u, d = 0, and we are done. Else,
142
143p = rm + t u,
144d = (1 - t) m.
145
146[1] See Lagrange relaxation