Group Abstract Group Abstract

Message Boards Message Boards

Simulated camera problem

Posted 3 years ago

I'd like to viewing a closed 3D surface at a fixed point vp amied to another point vc. I tried to employ the ViewVector to do it. But I was confused by the result when vp was nearby the outer boundary of the surface. It showed that the inside of the surface could be viewed even if the viewing point was outside the closed surface. It was not true when the surface was photographed by a real camera or viewing with an eye.

(* A 3D surface model *)
Li = {{100, -20}, {120, -10}, {120, 10}, {110, 30}, {90, 45}};
{m, p} = {Length[Li] - 1, 32};
ply = BSplineFunction[Li, SplineDegree -> 1];
pf[t_] := ply[t]
X[t_?NumericQ] := pf[t][[1]]
Z[t_?NumericQ] := pf[t][[2]]
vtx = Flatten[
   Table[{X[i/m] Cos[(2 j - 1) \[Pi]/p], 
     X[i/m] Sin[(2 j - 1) \[Pi]/p], Z[i/m]}, {i, 0, m}, {j, p}], 1];
id = Flatten[
   Table[{j, Mod[j + 1, p, i*p + 1], Mod[p + j + 1, p, (i + 1)*p + 1],
      p + j}, {i, 0, m - 1}, {j, i*p + 1, (i + 1)*p}], 1];
b3D = Graphics3D[{FaceForm[Pink, Cyan], 
    GraphicsComplex[vtx, Polygon[id]]}, Boxed -> False];
(* Viewing the surface with a simulated Camera *)
Manipulate[Module[{vp, vc, \[CurlyPhi]p = -3 \[Degree]},
  vp = {x0, -10, -12};(* viewing point *)
  vc = vp - {Sin[\[Theta]p] Cos[\[CurlyPhi]p], 
     Sin[\[Theta]p] Sin[\[CurlyPhi]p], Cos[\[Theta]p]};
  Show[b3D, ViewVector -> {vp, vc}, ViewAngle -> 140 \[Degree]]
  ], {{x0, 120.5, "Camera position"}, 110, 500, 
  0.1}, {{\[Theta]p, 135 \[Degree], "Direction"}, 90 \[Degree], 
  179 \[Degree], 1 \[Degree]}
 ]
Attachment

Attachment

Attachments:
POSTED BY: Jianhua Yang
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard