Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to find current ViewAngle, ViewPoint during Rotating graphics?

1,287 views
Skip to first unread message

Nasser Abbasi

unread,
Apr 12, 2009, 3:48:55 AM4/12/09
to
Mathematica 7.

Is there a way to display the current ViewAngle and/or View point of a 3D
graphics as one is rotating it with the mouse?

Sometimes I am not sure what is the best view angle to use initially, but
after I rotate the 3D graphics and find a good angle I like, there does not
seem to be a way to determine its value from the front end. I was expecting
may be that a mouse right-click on the graphics or something similar would
bring up some information about the current state of the graphics.

Any one knows a trick way to find this information?

Thanks,
--Nasser


David Park

unread,
Apr 13, 2009, 3:32:45 AM4/13/09
to
Make a Plot, say,

Plot3D[(x - 3) (y - 2), {x, 0, 5}, {y, 0, 5},
ImageSize -> 300]

Then in the output, position the cursor to the left of the plot and type
'AbsoluteOptions['. Next position the cursor to the right of the plot and
type ',ViewPoint]'. Evaluate and you will obtain the current ViewPoint. You
can rotate the image and reevaluate to get the new ViewPoint. Then copy the
ViewPoint into the original plot statement.

Without the ImageSize option it also works but I get warning messages after
rotating.


David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/

Nasser Abbasi

unread,
Apr 13, 2009, 3:33:50 AM4/13/09
to

From: "David Park" <djm...@comcast.net>


> Make a Plot, say,
>
> Plot3D[(x - 3) (y - 2), {x, 0, 5}, {y, 0, 5},
> ImageSize -> 300]
>
> Then in the output, position the cursor to the left of the plot and type
> 'AbsoluteOptions['. Next position the cursor to the right of the plot and
> type ',ViewPoint]'. Evaluate and you will obtain the current ViewPoint.
> You
> can rotate the image and reevaluate to get the new ViewPoint. Then copy
> the
> ViewPoint into the original plot statement.
>
> Without the ImageSize option it also works but I get warning messages
> after
> rotating.
>
>
> David Park
> djm...@comcast.net
> http://home.comcast.net/~djmpark/
>
>

Thanks David, but the above does not seem to work on my plot. I am using
this 3D plot

ParametricPlot3D[{Sin[u], Cos[u], 0.05*u}, {u, 0, 5*2*Pi}, PlotStyle ->
{Tube[thick]},
ViewPoint -> {2.645, 2.057138, 0.468316}, ViewAngle -> Automatic, Axes ->
False, Boxed -> False,
ImageSize -> 300]

And the above ViewPoint value was copied as a result of the method you
described, yet the resulting image orientation does not match that which I
copied the ViewPoint from.

Here is a screen shot.

http://12000.org/tmp/041209/viewpoint.PNG

Basically, I am trying to make a "spring" which is oriented sideways instead
of up-down.

This is on Mathematica 7

ps. You are right above getting a warning when not using ImageSize.

--Nasser

Albert Retey

unread,
Apr 13, 2009, 3:34:33 AM4/13/09
to

I don't know if this qualifies for tricky: if you recall that everything
is an expression, and since version 6 this is true also for displayed
graphics, then it is just the most natural thing to do...

Put this in front of the displayed Graphics3D and evaluate the resulting
expression:

AbsoluteOptions@


hth,

albert

Szabolcs Horvát

unread,
Apr 13, 2009, 3:35:06 AM4/13/09
to

This has come up when version 6 came out and the ViewPoint Selector was
removed.

http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/524cfa9d6aa9b6e0/7b047a2b7e252f5a

The concept is:

Graphics3D[Cylinder[], ViewPoint -> Dynamic[vp]]

Dynamic[vp]

Alexander Elkins

unread,
Apr 13, 2009, 3:36:11 AM4/13/09
to
> Is there a way to display the current ViewAngle and/or View point of a 3D
> graphics as one is rotating it with the mouse?

Here is an example showing how to connect Manipulate controls to the
options of Graphics3D. The trick is to use Dynamic and the correct initial
values:

Manipulate[
Graphics3D[Cuboid[], ViewPoint -> Dynamic[vp], ViewVertical -> Dynamic[vv],
ViewAngle -> Dynamic[va], ViewCenter -> Dynamic[vc], SphericalRegion ->
Dynamic[sr], Method -> {"RotationControl" -> Dynamic[rc]}], {{vp, ViewPoint
/. Options[Graphics3D], "ViewPoint\[Rule]"}, InputField}, {{vv, {0, 0, 1},
"ViewVertical\[Rule]"}, InputField}, {{va, Automatic, "ViewAngle\[Rule]"},
InputField}, {{vc, {{1/2, 1/2, 1/2}, {1/2, 1/2}}, "ViewCenter\[Rule]"},
InputField}, {{sr, True, "SphericalRegion\[Rule]"}, {True, False}}, {{rc,
"ArcBall", "Method"}, {"Globe", "ArcBall"}}]

Note that the "Globe" setting locks ViewVertical->{0, 0, 1} like Plot3D does
it.

Enjoy!
Alexander


John Fultz

unread,
Apr 14, 2009, 6:15:37 AM4/14/09
to
> described, yet the resulting image orientation does not match that which=

I
> copied the ViewPoint from.
>
> Here is a screen shot.
>
> http://12000.org/tmp/041209/viewpoint.PNG
>
> Basically, I am trying to make a "spring" which is oriented sideways
> instead
> of up-down.
>
> This is on Mathematica 7
>
> ps. You are right above getting a warning when not using ImageSize.
>
> --Nasser

You should be getting not only the ViewPoint, but the ViewVertical, as well.

Sincerely,

John Fultz
jfu...@wolfram.com
User Interface Group
Wolfram Research, Inc.

Alexander Elkins

unread,
Apr 14, 2009, 6:15:52 AM4/14/09
to
Here I've incorporated your 3D plot into my example. I've made the tube
optional since it slows things down. Note that
ViewPoint->{3.38378, 0, 0} with ViewVertical->{0,1,0} gives you a
"spring" which is oriented sideways.

Manipulate[


ParametricPlot3D[{Sin[u], Cos[u], 0.05*u}, {u, 0, 5*2*Pi},

PlotStyle -> If[tube, Tube[0.05], Automatic], Axes -> Dynamic[axes],
Boxed -> Dynamic[boxed], ImageSize -> 300, ViewPoint -> Dynamic[vp],


ViewVertical -> Dynamic[vv], ViewAngle -> Dynamic[va],
ViewCenter -> Dynamic[vc], SphericalRegion -> Dynamic[sr],
Method -> {"RotationControl" -> Dynamic[rc]}], {{vp,
ViewPoint /. Options[Graphics3D], "ViewPoint\[Rule]"},
InputField}, {{vv, {0, 0, 1}, "ViewVertical\[Rule]"},
InputField}, {{va, Automatic, "ViewAngle\[Rule]"},
InputField}, {{vc, {{1/2, 1/2, 1/2}, {1/2, 1/2}}, "ViewCenter\[Rule]"},
InputField},

Row[{Labeled[Checkbox[Dynamic[sr]], "SphericalRegion\[Rule]", Left,
Spacings -> 0],
Labeled[Checkbox[Dynamic[axes]], "Axes\[Rule]", Left, Spacings -> 0],
Labeled[Checkbox[Dynamic[boxed]], "Boxed\[Rule]", Left, Spacings -> 0],
Labeled[Checkbox[Dynamic[tube]], "Tube\[Rule]", Left,
Spacings -> 0]}], {sr, {True, False}, None}, {axes, {False, True},
None}, {boxed, {False, True}, None}, {tube, {False, True},
None}, {{rc, "ArcBall", "RotationControl\[Rule]"}, {"ArcBall", "Globe"}}]

Enjoy!
Alexander

"Nasser Abbasi" <n...@12000.org> wrote in message
news:grupsu$rp$1...@smc.vnet.net...

Peter Breitfeld

unread,
Apr 16, 2009, 4:13:45 AM4/16/09
to
"Nasser Abbasi" wrote:

For this purpose I use the following function:

ExtrahiereViews[pl_]:=
Flatten[Union[(Extract[pl,Position[pl,#]]&)/@
{ViewPoint->_, ViewCenter->_, ViewVertical->_,
ViewAngle->_, ViewVector->_, ViewRange->_} ]]

Give your "moused" image as argument to it

--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de

0 new messages