--- /dev/null
+(* Content-type: application/vnd.wolfram.mathematica *)
+
+(*** Wolfram Notebook File ***)
+(* http://www.wolfram.com/nb *)
+
+(* CreatedBy='Mathematica 9.0' *)
+
+(*CacheID: 234*)
+(* Internal cache information:
+NotebookFileLineBreakTest
+NotebookFileLineBreakTest
+NotebookDataPosition[ 157, 7]
+NotebookDataLength[ 8384, 285]
+NotebookOptionsPosition[ 7404, 248]
+NotebookOutlinePosition[ 7739, 263]
+CellTagsIndexPosition[ 7696, 260]
+WindowFrame->Normal*)
+
+(* Beginning of Notebook Content *)
+Notebook[{
+Cell[TextData[{
+ "The view \[OpenCurlyDoubleQuote]scale about point\[CloseCurlyDoubleQuote] \
+transformation\nmx, my is mouse coordinates ",
+ StyleBox["relative to the view",
+ FontSlant->"Italic"],
+ "\nx, y, w, h are current view coordinates ",
+ StyleBox["relative to the document",
+ FontSlant->"Italic"],
+ "\nX, Y, W, H are transformed coordinates\nThis operation cannot be \
+represented as a 2D matrix operation..."
+}], "Text",
+ CellChangeTimes->{{3.621645547391625*^9, 3.621645590446886*^9}, {
+ 3.621645788609687*^9, 3.621645803583606*^9}}],
+
+Cell[BoxData[{
+ RowBox[{
+ RowBox[{"vx", " ", "=", " ",
+ RowBox[{
+ RowBox[{"w", " ", "*", "mx"}], " ", "+", " ", "x"}]}],
+ ";"}], "\[IndentingNewLine]",
+ RowBox[{
+ RowBox[{"vy", " ", "=", " ",
+ RowBox[{
+ RowBox[{"h", " ", "*", " ", "my"}], " ", "+", " ", "y"}]}],
+ ";"}], "\[IndentingNewLine]",
+ RowBox[{
+ RowBox[{"top", " ", "=", " ",
+ RowBox[{"vy", " ", "-", " ", "y"}]}], ";"}], "\[IndentingNewLine]",
+ RowBox[{
+ RowBox[{"left", " ", "=", " ",
+ RowBox[{"vx", " ", "-", " ", "x"}]}], ";"}], "\[IndentingNewLine]",
+ RowBox[{
+ RowBox[{"top", " ", "=", " ",
+ RowBox[{"top", "*", "s"}]}], ";"}], "\[IndentingNewLine]",
+ RowBox[{
+ RowBox[{"left", " ", "=", " ",
+ RowBox[{"left", " ", "*", " ", "s"}]}], ";"}], "\[IndentingNewLine]",
+ RowBox[{
+ RowBox[{"X", " ", "=", " ",
+ RowBox[{"vx", " ", "-", " ", "left"}]}], ";"}], "\[IndentingNewLine]",
+ RowBox[{
+ RowBox[{"Y", " ", "=", " ",
+ RowBox[{"vy", " ", "-", " ", "top"}]}], ";"}], "\[IndentingNewLine]",
+ RowBox[{
+ RowBox[{"W", " ", "=", " ",
+ RowBox[{"w", "*", "s"}]}], ";"}], "\[IndentingNewLine]",
+ RowBox[{
+ RowBox[{"H", " ", "=", " ",
+ RowBox[{"h", "*", "s"}]}], ";"}]}], "Input",
+ CellChangeTimes->{{3.621644450038117*^9, 3.621644517724819*^9}, {
+ 3.6216455001839314`*^9, 3.6216455061448193`*^9}}],
+
+Cell[CellGroupData[{
+
+Cell[BoxData[
+ RowBox[{"xy1", " ", "=", " ",
+ RowBox[{"{",
+ RowBox[{
+ RowBox[{"{",
+ RowBox[{"x", ",", "y"}], "}"}], ",",
+ RowBox[{"{",
+ RowBox[{"x", "+", "w"}], "}"}], ",",
+ RowBox[{"{",
+ RowBox[{"y", "+", "h"}], "}"}]}], "}"}]}]], "Input",
+ CellChangeTimes->{{3.621645646537537*^9, 3.621645677183116*^9}}],
+
+Cell[BoxData[
+ RowBox[{"{",
+ RowBox[{
+ RowBox[{"{",
+ RowBox[{"x", ",", "y"}], "}"}], ",",
+ RowBox[{"{",
+ RowBox[{"w", "+", "x"}], "}"}], ",",
+ RowBox[{"{",
+ RowBox[{"h", "+", "y"}], "}"}]}], "}"}]], "Output",
+ CellChangeTimes->{3.62164567753369*^9}]
+}, Open ]],
+
+Cell[CellGroupData[{
+
+Cell[BoxData[
+ RowBox[{"xy2", " ", "=", " ",
+ RowBox[{"FullSimplify", "[",
+ RowBox[{"{",
+ RowBox[{"X", ",", " ", "Y", ",", " ",
+ RowBox[{"X", "+", "W"}], ",", " ",
+ RowBox[{"Y", "+", "H"}]}], "}"}], "]"}]}]], "Input",
+ CellChangeTimes->{{3.62164452159755*^9, 3.621644525242661*^9}, {
+ 3.621645606946629*^9, 3.621645623731018*^9}, {3.6216456891302*^9,
+ 3.621645689867572*^9}}],
+
+Cell[BoxData[
+ RowBox[{"{",
+ RowBox[{
+ RowBox[{
+ RowBox[{"mx", " ",
+ RowBox[{"(",
+ RowBox[{"w", "-",
+ RowBox[{"s", " ", "w"}]}], ")"}]}], "+", "x"}], ",",
+ RowBox[{
+ RowBox[{"h", " ",
+ RowBox[{"(",
+ RowBox[{"my", "-",
+ RowBox[{"my", " ", "s"}]}], ")"}]}], "+", "y"}], ",",
+ RowBox[{
+ RowBox[{
+ RowBox[{"(",
+ RowBox[{"mx", "+", "s", "-",
+ RowBox[{"mx", " ", "s"}]}], ")"}], " ", "w"}], "+", "x"}], ",",
+ RowBox[{
+ RowBox[{"h", " ",
+ RowBox[{"(",
+ RowBox[{"my", "+", "s", "-",
+ RowBox[{"my", " ", "s"}]}], ")"}]}], "+", "y"}]}], "}"}]], "Output",
+ CellChangeTimes->{
+ 3.621644525784692*^9, {3.621645598921043*^9, 3.62164562472651*^9}, {
+ 3.621645679592589*^9, 3.6216456913785887`*^9}}]
+}, Open ]],
+
+Cell[CellGroupData[{
+
+Cell[BoxData[
+ RowBox[{"xywh2", " ", "=", " ",
+ RowBox[{"FullSimplify", "[",
+ RowBox[{"{",
+ RowBox[{"X", ",", " ", "Y", ",", " ", "W", ",", "H"}], "}"}],
+ "]"}]}]], "Input",
+ CellChangeTimes->{{3.621645929284232*^9, 3.621645939176342*^9}}],
+
+Cell[BoxData[
+ RowBox[{"{",
+ RowBox[{
+ RowBox[{
+ RowBox[{"mx", " ",
+ RowBox[{"(",
+ RowBox[{"w", "-",
+ RowBox[{"s", " ", "w"}]}], ")"}]}], "+", "x"}], ",",
+ RowBox[{
+ RowBox[{"h", " ",
+ RowBox[{"(",
+ RowBox[{"my", "-",
+ RowBox[{"my", " ", "s"}]}], ")"}]}], "+", "y"}], ",",
+ RowBox[{"s", " ", "w"}], ",",
+ RowBox[{"h", " ", "s"}]}], "}"}]], "Output",
+ CellChangeTimes->{3.621645939693961*^9}]
+}, Open ]],
+
+Cell[TextData[{
+ "For primitives in document,\nV X \[Rule] V X + S[V X - ",
+ Cell[BoxData[
+ FormBox[
+ RowBox[{
+ SubscriptBox["X", "0"], "]"}], TraditionalForm]],
+ FormatType->"TraditionalForm"],
+ "\nV is view matrix, S is scale matrix"
+}], "Text",
+ CellChangeTimes->{{3.62164641213169*^9, 3.62164647339319*^9}}],
+
+Cell[BoxData[
+ RowBox[{
+ RowBox[{"(*",
+ RowBox[{"TODO", ":", " ",
+ RowBox[{"Express", " ", "as", " ", "a", " ", "matrix", " ",
+ RowBox[{"operation", "?"}]}]}], "*)"}], "\[IndentingNewLine]"}]], "Input",\
+
+ CellChangeTimes->{{3.6216459415176992`*^9, 3.621645948934423*^9}, {
+ 3.6216463980527067`*^9, 3.6216464053607597`*^9}}],
+
+Cell[BoxData[
+ RowBox[{"ClearAll", "[",
+ RowBox[{"Evaluate", "[",
+ RowBox[{
+ RowBox[{"Context", "[", "]"}], "<>", "\"\<*\>\""}], "]"}], "]"}]], "Input"],
+
+Cell["Floating point operations", "Text",
+ CellChangeTimes->{{3.621665522093079*^9, 3.6216655239496813`*^9}}],
+
+Cell[BoxData[
+ RowBox[{"FullSimplify", "[",
+ RowBox[{"m1", " ",
+ SuperscriptBox["B", "e1"], " ", "*", " ", "m2", " ",
+ SuperscriptBox["B", "e2"]}], "]"}]], "Input",
+ CellChangeTimes->{{3.621665107840431*^9, 3.6216651376842957`*^9}}],
+
+Cell[BoxData[
+ RowBox[{
+ SuperscriptBox["B",
+ RowBox[{"e1", "+", "e2"}]], " ", "m1", " ", "m2"}]], "Input",
+ CellChangeTimes->{{3.62166519824517*^9, 3.62166520820506*^9}}],
+
+Cell[BoxData[
+ RowBox[{
+ SuperscriptBox["B",
+ RowBox[{"e1", "+", "e2"}]], " ", "m1", " ", "m2"}]], "Output",
+ CellChangeTimes->{{3.621665204836622*^9, 3.621665208534109*^9}}],
+
+Cell[CellGroupData[{
+
+Cell[BoxData[
+ RowBox[{"FullSimplify", "[",
+ RowBox[{"Solve", "[",
+ RowBox[{
+ RowBox[{
+ RowBox[{
+ RowBox[{"m1", " ",
+ SuperscriptBox["B", "e1"]}], " ", "+", " ",
+ RowBox[{"m2", " ",
+ SuperscriptBox["B", "e2"]}]}], " ", "\[Equal]", " ",
+ RowBox[{"m3", " ",
+ SuperscriptBox["B", "e1"]}]}], ",", " ", "m3"}], "]"}], "]"}]], "Input",\
+
+ CellChangeTimes->{
+ 3.621665148857037*^9, {3.621665392367518*^9, 3.62166542126152*^9}}],
+
+Cell[BoxData[
+ RowBox[{"{",
+ RowBox[{"{",
+ RowBox[{"m3", "\[Rule]",
+ RowBox[{"m1", "+",
+ RowBox[{
+ SuperscriptBox["B",
+ RowBox[{
+ RowBox[{"-", "e1"}], "+", "e2"}]], " ", "m2"}]}]}], "}"}],
+ "}"}]], "Output",
+ CellChangeTimes->{
+ 3.621665149470646*^9, {3.621665400108696*^9, 3.621665421774309*^9}}]
+}, Open ]]
+},
+WindowSize->{740, 575},
+WindowMargins->{{Automatic, 79}, {Automatic, 0}},
+FrontEndVersion->"9.0 for Linux x86 (64-bit) (February 7, 2013)",
+StyleDefinitions->"Default.nb"
+]
+(* End of Notebook Content *)
+
+(* Internal cache information *)
+(*CellTagsOutline
+CellTagsIndex->{}
+*)
+(*CellTagsIndex
+CellTagsIndex->{}
+*)
+(*NotebookFileOutline
+Notebook[{
+Cell[557, 20, 546, 12, 110, "Text"],
+Cell[1106, 34, 1309, 36, 231, "Input"],
+Cell[CellGroupData[{
+Cell[2440, 74, 337, 10, 32, "Input"],
+Cell[2780, 86, 271, 9, 32, "Output"]
+}, Open ]],
+Cell[CellGroupData[{
+Cell[3088, 100, 397, 9, 32, "Input"],
+Cell[3488, 111, 782, 25, 32, "Output"]
+}, Open ]],
+Cell[CellGroupData[{
+Cell[4307, 141, 251, 6, 32, "Input"],
+Cell[4561, 149, 446, 15, 32, "Output"]
+}, Open ]],
+Cell[5022, 167, 318, 9, 71, "Text"],
+Cell[5343, 178, 338, 8, 55, "Input"],
+Cell[5684, 188, 160, 4, 32, "Input"],
+Cell[5847, 194, 109, 1, 30, "Text"],
+Cell[5959, 197, 240, 5, 35, "Input"],
+Cell[6202, 204, 175, 4, 32, "Input"],
+Cell[6380, 210, 178, 4, 32, "Output"],
+Cell[CellGroupData[{
+Cell[6583, 218, 469, 14, 35, "Input"],
+Cell[7055, 234, 333, 11, 35, "Output"]
+}, Open ]]
+}
+]
+*)
+
+(* End of internal cache information *)