(*Copyright 1990 Wolfram Research Inc. *)

(** Control Functions for 3D Stereo ViewPoint **)

(* MSDOS specific by T. Sherlock *)
(*Udated by Larry Calmer *)
(*Ported to the SGI by Larry Calmer *)

Options[View3D]={AngSep->.04,AspectRatio3D->.47,
ViewPoint3D->{1.3,-2.4,.5},
Window3D->{{7,982},{1272,512},{7,452},{1272,-18}},
FileSave->False}


BeginPackage["View3D`", "Global`"]

View3D::usage = "View3D['graphics'], Options:  AngSep, AspectRatio3D, FileSave, ViewPoint3D"

AngSep::usage = "Angular Seperation of two view points, Real Number in Radians"

ViewPoint3D::usage = "a list of 3 real numbers {x,y,z}, placement of view point other than default value of graphic object"

AspectRatio3D::usage = " a Real value for the stereo display device you are using, (will also affect files saved to disk)"

Window3D::usage = "a list of 4 Integer Pairs  {{ULL},{LRL},{ULR},{LRR}}, specifying the upper left, and lower right of the left image window & the upper left, and lower right of the right image window"

FileSave::usage = "FileSave -> False, Default.  Setting to True will induce a prompt for the File Name (use quotes)"

Begin["`Private`"]

View3D[the3DGraphic_,opts___Rule] := Block[
{Gl,Gr,disp,centerview,eyeline,ueyeline,viewdist,eyedist,
VecLen,Cross,centerline,leftview,rightview,VP,AS,AR,WD,FS,t,name},
VP = ViewPoint3D /.   {opts} /. Options[View3D];
AS = AngSep /.        {opts} /. Options[View3D];
AR = AspectRatio3D /. {opts} /. Options[View3D];
WD = Window3D /.      {opts} /. Options[View3D];
FS = FileSave /.      {opts} /. Options[View3D];

centerview = VP;

VecLen[{x_, y_, z_}] := Sqrt[N[x ^2 + y ^2 + z ^2]];
Cross[u_List, v_List] := Det[{{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, u, v}];

centerline = {0.0, 0.0, -1.0};
eyeline = Cross[centerline, centerview];
ueyeline = eyeline / VecLen[eyeline];
viewdist = VecLen[centerview];
eyedist = viewdist / 24;
leftview = centerview + eyedist * ueyeline;
rightview = centerview - eyedist * ueyeline;

Print ["  Left View Point "];
Print [leftview];

Print [" Right View Point "];
Print [rightview];

If[FS,
Print["Saving File"];
name=Input["Name of File to Save? "];
FS=!Input["Show Stereo Image on Screen? (True/False) "];

disp=$Display;
$Display = StringJoin[name,"left.ps"];

Show[the3DGraphic,ViewPoint->leftview,
AspectRatio->AR
];

$Display = StringJoin[name,"right.ps"];

Show[the3DGraphic,ViewPoint->rightview,
AspectRatio->AR
];

$Display=disp
];

If[!FS,
$DisplayWidth=WD[[2,1]]-WD[[1,1]];
$DisplayY=WD[[2,2]];
$DisplayX=WD[[1,1]];
$DisplayHeight=WD[[1,2]]-WD[[2,2]];

Show[the3DGraphic,ViewPoint->rightview,
AspectRatio->AR
];

$DisplayWidth=WD[[4,1]]-WD[[3,1]]; 
$DisplayY=WD[[4,2]];
$DisplayX=WD[[3,1]]; 
$DisplayHeight=WD[[3,2]]-WD[[4,2]]; 

Show[the3DGraphic,ViewPoint->leftview,
AspectRatio->AR
]
]
]
End[]
EndPackage[]

Print ["-- View3D Function Loaded --"]

--------------------------------
End of part 1 of 1

From ms-admin@wri.com Wed Mar 18 22:43:58 1992
To: kriz@wave.esm.vt.edu (Ronald D. Kriz VIMS)
Subject: MathSource Subitem 0201-946-0123 [1 of 1]

This is an automatic response from the MathSource server at ms-request@wri.com.

To prevent infinte loops within the MathSource server due to
returned mail, this mail is sent from ms-admin@wri.com.  If you
reply to this message, the mail will go to a human operator and
NOT to the MathSource server.

The system is currently being tested.  Please report all problems
and suggestions to ms-admin@wri.com.

Sent for request of  Wed, 18 Mar 92 22:43:37 EST
Part 1 of 1
--------------------------------
(*Copyright 1990 Wolfram Research Inc. *)

(** Control Functions for 3D Stereo ViewPoint **)

(* MSDOS specific by T. Sherlock *)
(*Udated by Larry Calmer *)
(*Ported to the SGI by Larry Calmer *)

Options[View3D]={AngSep->.04,AspectRatio3D->.47,
ViewPoint3D->{1.3,-2.4,.5},
Window3D->{{7,982},{1272,512},{7,452},{1272,-18}},
FileSave->False}


BeginPackage["View3D`", "Global`"]

View3D::usage = "View3D['graphics'], Options:  AngSep, AspectRatio3D, FileSave, ViewPoint3D"

AngSep::usage = "Angular Seperation of two view points, Real Number in Radians"

ViewPoint3D::usage = "a list of 3 real numbers {x,y,z}, placement of view point other than default value of graphic object"

AspectRatio3D::usage = " a Real value for the stereo display device you are using, (will also affect files saved to disk)"

Window3D::usage = "a list of 4 Integer Pairs  {{ULL},{LRL},{ULR},{LRR}}, specifying the upper left, and lower right of the left image window & the upper left, and lower right of the right image window"

FileSave::usage = "FileSave -> False, Default.  Setting to True will induce a prompt for the File Name (use quotes)"

Begin["`Private`"]

View3D[the3DGraphic_,opts___Rule] := Block[
{Gl,Gr,disp,centerview,eyeline,ueyeline,viewdist,eyedist,
VecLen,Cross,centerline,leftview,rightview,VP,AS,AR,WD,FS,t,name},
VP = ViewPoint3D /.   {opts} /. Options[View3D];
AS = AngSep /.        {opts} /. Options[View3D];
AR = AspectRatio3D /. {opts} /. Options[View3D];
WD = Window3D /.      {opts} /. Options[View3D];
FS = FileSave /.      {opts} /. Options[View3D];

centerview = VP;

VecLen[{x_, y_, z_}] := Sqrt[N[x ^2 + y ^2 + z ^2]];
Cross[u_List, v_List] := Det[{{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, u, v}];

centerline = {0.0, 0.0, -1.0};
eyeline = Cross[centerline, centerview];
ueyeline = eyeline / VecLen[eyeline];
viewdist = VecLen[centerview];
eyedist = viewdist / 24;
leftview = centerview + eyedist * ueyeline;
rightview = centerview - eyedist * ueyeline;

Print ["  Left View Point "];
Print [leftview];

Print [" Right View Point "];
Print [rightview];

If[FS,
Print["Saving File"];
name=Input["Name of File to Save? "];
FS=!Input["Show Stereo Image on Screen? (True/False) "];

disp=$Display;
$Display = StringJoin[name,"left.ps"];

Show[the3DGraphic,ViewPoint->leftview,
AspectRatio->AR
];

$Display = StringJoin[name,"right.ps"];

Show[the3DGraphic,ViewPoint->rightview,
AspectRatio->AR
];

$Display=disp
];

If[!FS,
$DisplayWidth=WD[[2,1]]-WD[[1,1]];
$DisplayY=WD[[2,2]];
$DisplayX=WD[[1,1]];
$DisplayHeight=WD[[1,2]]-WD[[2,2]];

Show[the3DGraphic,ViewPoint->rightview,
AspectRatio->AR
];

$DisplayWidth=WD[[4,1]]-WD[[3,1]]; 
$DisplayY=WD[[4,2]];
$DisplayX=WD[[3,1]]; 
$DisplayHeight=WD[[3,2]]-WD[[4,2]]; 

Show[the3DGraphic,ViewPoint->leftview,
AspectRatio->AR
]
]
]
End[]
EndPackage[]

Print ["-- View3D Function Loaded --"]
