一般の平面への透視投影（計算）

定義

同次座標から直交座標へ

HomToOrth3D[list_]:={list[[1]]/list[[4]],list[[2]]/list[[4]],list[[3]]/list[[4]]}

透視投影

PersP[VP_,normalV_,C_][point_]:=point+((C-point.normalV)/((VP-point).normalV))(VP-point)

例題 3.7（例題 3.5）

投影面，視点，点P

Show[
ContourPlot3D[x+y-z==2,{x,-5,5},{y,-5,5},{z,-5,5}],
Graphics3D[{Red,PointSize[0.02],Point[{8,9,-6}]}],
Graphics3D[{Blue,PointSize[0.02],Point[{3,2,-1}]}],
PlotRange->All
]

直交行列 M（例題 3.5）

M=(({{1/Sqrt[3], 1/Sqrt[2], -1/Sqrt[6]}, {1/Sqrt[3], -1/Sqrt[2], -1/Sqrt[6]}, {-1/Sqrt[3], 0, -2/Sqrt[6]}}))

M//MatrixForm

ベクトル u（例題 3.5）

VecU={1,1,0}

同次座標系の座標変換

Transpose[M]//MatrixForm

-Transpose[M].VecU//MatrixForm

Transpose[M]//MatrixForm

(({{(1/(Sqrt[3])), (1/(Sqrt[3])), -(1/(Sqrt[3])), -(2/(Sqrt[3]))}, {(1/(Sqrt[2])), -(1/(Sqrt[2])), 0, 0}, {-(1/(Sqrt[6])), -(1/(Sqrt[6])), -(Sqrt[(2/3)]), (Sqrt[(2/3)])}, {0, 0, 0, 1}}))

視点Vの座標変換後の座標

Simplify[(({{(1/(Sqrt[3])), (1/(Sqrt[3])), -(1/(Sqrt[3])), -(2/(Sqrt[3]))}, {(1/(Sqrt[2])), -(1/(Sqrt[2])), 0, 0}, {-(1/(Sqrt[6])), -(1/(Sqrt[6])), -(Sqrt[(2/3)]), (Sqrt[(2/3)])}, {0, 0, 0, 1}})).{8,9,-6,1}]

(Sqrt[6])*{7 (Sqrt[3]),-(1/(Sqrt[2])),-(Sqrt[(3/2)]),1}

透視投影を表す行列

Simplify[(({{(1/(Sqrt[3])), (1/(Sqrt[2])), -(1/(Sqrt[6])), 1}, {(1/(Sqrt[3])), -(1/(Sqrt[2])), -(1/(Sqrt[6])), 1}, {-(1/(Sqrt[3])), 0, -(Sqrt[(2/3)]), 0}, {0, 0, 0, 1}})).(({{0, 0, 0, 0}, {(Sqrt[3]), 21 (Sqrt[2]), 0, 0}, {3, 0, 21 (Sqrt[2]), 0}, {-(Sqrt[6]), 0, 0, 21 (Sqrt[2])}})).(({{(1/(Sqrt[3])), (1/(Sqrt[3])), -(1/(Sqrt[3])), -(2/(Sqrt[3]))}, {(1/(Sqrt[2])), -(1/(Sqrt[2])), 0, 0}, {-(1/(Sqrt[6])), -(1/(Sqrt[6])), -(Sqrt[(2/3)]), (Sqrt[(2/3)])}, {0, 0, 0, 1}}))]//MatrixForm

点Pを透視投影（同次座標）

(({{13 (Sqrt[2]), -8 (Sqrt[2]), 8 (Sqrt[2]), 16 (Sqrt[2])}, {-9 (Sqrt[2]), 12 (Sqrt[2]), 9 (Sqrt[2]), 18 (Sqrt[2])}, {6 (Sqrt[2]), 6 (Sqrt[2]), 15 (Sqrt[2]), -12 (Sqrt[2])}, {-(Sqrt[2]), -(Sqrt[2]), (Sqrt[2]), 23 (Sqrt[2])}})).{3,2,-1,1}

点Pの透視像を直交座標に変換

Simplify[HomToOrth3D[(({{13 (Sqrt[2]), -8 (Sqrt[2]), 8 (Sqrt[2]), 16 (Sqrt[2])}, {-9 (Sqrt[2]), 12 (Sqrt[2]), 9 (Sqrt[2]), 18 (Sqrt[2])}, {6 (Sqrt[2]), 6 (Sqrt[2]), 15 (Sqrt[2]), -12 (Sqrt[2])}, {-(Sqrt[2]), -(Sqrt[2]), (Sqrt[2]), 23 (Sqrt[2])}})).{3,2,-1,1}]]

透視投影の公式を用いて直接点Pの像を計算（検算）

PersP[{8,9,-6},{1,1,-1},2][{3,2,-1}]

Show[
ContourPlot3D[x+y-z==2,{x,-5,5},{y,-5,5},{z,-5,5}],
Graphics3D[{Red,PointSize[0.02],Point[{8,9,-6}]}],
Graphics3D[{Blue,PointSize[0.02],Point[{3,2,-1}]}],
Graphics3D[{Green,PointSize[0.02],Point[{(31/17),(6/17),(3/17)}]}],
PlotRange->All
]

問題 3.8（問題 3.6）

Show[
ContourPlot3D[3x-4y+5z==6,{x,-8,8},{y,-8,8},{z,-8,8}],
Graphics3D[{Red,PointSize[0.02],Point[{8,-9,6}]}],
Graphics3D[{Blue,PointSize[0.02],Point[{3,2,-1}]}],
PlotRange->All
]