Unexpected $vpr behavior

classic Classic list List threaded Threaded
19 messages Options
Reply | Threaded
Open this post in threaded view
|

Unexpected $vpr behavior

OpenSCAD mailing list-2
The "viewport rotation" special variable doesn't behave like I expect. I
expect the view to rotate around whichever axis is changed, therefore it
should stay still on my computer screen.

Take this code for example:

$vpr = [55, 0, 25];
text("Hello");

When I change the z-axis by 20 degrees, it does not move on my computer
screen.

But when I change the x- or y-axes by 20 degrees, they move substantially.

Is this a bug or am I not understanding something?




--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

skypuppy
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

OpenSCAD mailing list-2
This issue is not related to the text, just the axes. I should've left that
text line out.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

nophead
Not sure what you mean. If I change the z rotation to 45 and do F5 the text does rotate substantially.

image.png

On Tue, 8 Dec 2020 at 19:24, bmihuraca via Discuss <[hidden email]> wrote:
This issue is not related to the text, just the axes. I should've left that
text line out.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

JordanBrown
In reply to this post by skypuppy
On 12/8/2020 11:00 AM, David wrote:
Isn't text handled differently in OpenSCAD?  It's not handled as most graphics primitives except sometimes.

Text is a 2D object.  For display purposes it, like other 2D objects, has a bit of height, but they're all still 2D.

On 12/8/20 12:53 PM, bmihuraca via Discuss wrote:
The "viewport rotation" special variable doesn't behave like I expect. I
expect the view to rotate around whichever axis is changed, therefore it
should stay still on my computer screen.

Take this code for example:

$vpr = [55, 0, 25];
text("Hello");

When I change the z-axis by 20 degrees, it does not move on my computer
screen.

But when I change the x- or y-axes by 20 degrees, they move substantially.

Is this a bug or am I not understanding something?

I have trouble visualizing it myself, but I think what you're seeing is one of three things:
  • When you rotate in two axes, there's a related rotation in the third.
  • Like other OpenSCAD rotations, the Z rotation is done last.
  • View rotation is around the center of the window.  If the origin isn't at the center of the window, rotating around Z causes the Z axis to move too.

Try playing with one axis at a time, keeping the other two set to zero.

Set this animation going, then pan with your mouse and manually change the numbers for the rotation of the two non-animated axes:

$vpr = [0,0, $t*360];
text("Hello"); 

(If you're not familiar with animation:  View/Animate to get the controls to appear, then put (say) 10 in the FPS box and 90 in the Steps box.)

Of course, you can move the $t*360 to whichever axis you like.

You might also set

$vpt=[0,0,0];

to force the origin to the center.

Caution:  animated rotation of more than one axis a can make you dizzy!



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

OpenSCAD mailing list-2
Ack, everybody is focused on the text! I am only concerned about the axes.

Next month I'll post the same question without the line of text.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

nophead
I still don't understand what you mean. The text is always aligned with X and Y axes. The view angles changes according to the GUI or the $vpr setting that initially sets the GUI value but the mouse can change it until F5 is hit again. 

On Tue, 8 Dec 2020 at 19:58, bmihuraca via Discuss <[hidden email]> wrote:
Ack, everybody is focused on the text! I am only concerned about the axes.

Next month I'll post the same question without the line of text.



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

JordanBrown
In reply to this post by OpenSCAD mailing list-2
On 12/8/2020 11:58 AM, bmihuraca via Discuss wrote:
Ack, everybody is focused on the text! I am only concerned about the axes.


No, sorry, I got what you meant.  I responded to the other guy's text comment, and then to yours; perhaps I erred in combining the two and you missed the response to your question.

Here it is again.  I've retained the text() invocation from your original.  It's not necessary for the demonstration, but it can help keep track of which axis is which as you spin the world around.

---

I have trouble visualizing it myself, but I think what you're seeing is one of three things:
  • When you rotate in two axes, there's a related rotation in the third.
  • Like other OpenSCAD rotations, the Z rotation is done last.
  • View rotation is around the center of the window.  If the origin isn't at the center of the window, rotating around Z causes the Z axis to move too.

Try playing with one axis at a time, keeping the other two set to zero.

Set this animation going, then pan with your mouse and manually change the numbers for the rotation of the two non-animated axes:

$vpr = [0,0, $t*360];
text("Hello"); 

(If you're not familiar with animation:  View/Animate to get the controls to appear, then put (say) 10 in the FPS box and 90 in the Steps box.)

Of course, you can move the $t*360 to whichever axis you like.

You might also set

$vpt=[0,0,0];

to force the origin to the center.

Caution:  animated rotation of more than one axis a can make you dizzy!



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

JordanBrown
Another note:

Again, I have some trouble visualizing what's really going on and why, but note that OpenSCAD's viewer normally constrains rotation.  I'm not quite sure what the constraint is or what it deeply means, but as long as you're centered on the origin ($vpt=[0,0,0]; look at the bottom of the window) you can't get the Z axis to appear off vertical.  (It can tilt towards you or away from you, but never left or right.)

Another way to look at it is that if you're looking at a model of a globe (ignoring axial tilt), you can't get the north pole to be on the left or right side.

Probably strongly related is that the ordinary mouse controls never change the Y axis rotation - it's always zero.  (Watch the rotation numbers at the bottom of the screen.)

I suspect that the X and Z axis rotations map to altitude and azimuth, or in spherical coordinates theta θ and phi φ.

When you set $vpr, you can set the Y rotation and so you can move the Z axis off vertical.  For instance, [0,90,0] has the north pole pointed left.

(And forcing the Y rotation non-zero using $vpr then yields strange effects in the mouse-based rotation.)

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

OpenSCAD mailing list-2
I didn't explain it well enough to begin with; here's a picture (hopefully),
and I would expect the x-axis to have the same angle:

<http://forum.openscad.org/file/t3042/OpenSCAD_%24vpr_issue.png>





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

MichaelAtOz
Administrator
In reply to this post by JordanBrown
JordanBrown wrote
> I'm not quite sure what the constraint is or what it deeply means, but as
> long
> as you're centered on the origin ($vpt=[0,0,0]; look at the bottom of
> the window) you can't get the Z axis to appear off vertical.  (It can
> tilt towards you or away from you, but never left or right.)

Jordan, try Shift-drag.

Bruce,

Try this with Animate;

cube([100,10,10]);
cylinder(r=5,h=100,center=true);
$vpr=[$vpr[0],$vpr[1],$t*360];

Then drag & shift-drag. Note the rotate=[] at the bottom of the window.
Noting $vpr=[?,?,nnn] rotates AROUND Z.

Replace the third value with $vpr[2], then use $t*360 in X then Y.
Then make all three $t*360.



-----
OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

MichaelAtOz
Administrator
Here is a better one;

Rotate_x=false;
Rotate_y=false;
Rotate_z=false;

cube([100,10,10]);
cylinder(r=5,h=100,center=true);
$vpr=[  (Rotate_x) ? $t*360 : $vpr.x,
        (Rotate_y) ? $t*360 : $vpr.y,
        (Rotate_z) ? $t*360 : $vpr.z];

Show customizer, then select which axis to rotate dynamically.

Select one at a time, then use the Top/Bottom/Left/Right/Front/Back cube
buttons to explore what is rotating.

Now, the Viewport axes are X - left/right, Y - up/down, that is related to
the screen.

Now I see what bmihuraca is on about.

You would expect Z to then be AROUND the viewport depth axis, but it rotates
around the 3d-space X/Y plain.

Hmmm...








-----
OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

Whosawhatsis
The viewport's depth axis is Y, not Z. If you rotate Y (which you can't do with your mouse, but you can do with $vpr), the Z axis will tilt in the display. X is pitch, Y is roll, Z is yaw.

On December 8, 2020 at 15:19:13, MichaelAtOz ([hidden email]) wrote:

Here is a better one;

Rotate_x=false;
Rotate_y=false;
Rotate_z=false;

cube([100,10,10]);
cylinder(r=5,h=100,center=true);
$vpr=[ (Rotate_x) ? $t*360 : $vpr.x,
(Rotate_y) ? $t*360 : $vpr.y,
(Rotate_z) ? $t*360 : $vpr.z];

Show customizer, then select which axis to rotate dynamically.

Select one at a time, then use the Top/Bottom/Left/Right/Front/Back cube
buttons to explore what is rotating.

Now, the Viewport axes are X - left/right, Y - up/down, that is related to
the screen.

Now I see what bmihuraca is on about.

You would expect Z to then be AROUND the viewport depth axis, but it rotates
around the 3d-space X/Y plain.

Hmmm...








-----
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

Whosawhatsis
I will say, though, that given this, it's odd that $vpr = [0, 0, 0] gives you a top-down view. [0,  0, 0] being a front view would be more consistent...

On December 8, 2020 at 15:33:14, Whosawhatsis ([hidden email]) wrote:

The viewport's depth axis is Y, not Z. If you rotate Y (which you can't do with your mouse, but you can do with $vpr), the Z axis will tilt in the display. X is pitch, Y is roll, Z is yaw.

On December 8, 2020 at 15:19:13, MichaelAtOz ([hidden email]) wrote:

Here is a better one;

Rotate_x=false;
Rotate_y=false;
Rotate_z=false;

cube([100,10,10]);
cylinder(r=5,h=100,center=true);
$vpr=[ (Rotate_x) ? $t*360 : $vpr.x,
(Rotate_y) ? $t*360 : $vpr.y,
(Rotate_z) ? $t*360 : $vpr.z];

Show customizer, then select which axis to rotate dynamically.

Select one at a time, then use the Top/Bottom/Left/Right/Front/Back cube
buttons to explore what is rotating.

Now, the Viewport axes are X - left/right, Y - up/down, that is related to
the screen.

Now I see what bmihuraca is on about.

You would expect Z to then be AROUND the viewport depth axis, but it rotates
around the 3d-space X/Y plain.

Hmmm...








-----
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

MichaelAtOz
Administrator
In reply to this post by Whosawhatsis
Whosawhatsis wrote
> If you rotate Y (which you can't do with your mouse, but you can do with
> $vpr), the Z axis will tilt in the
> display.

You can with shift-drag.
Do Reset-view, then View-top.
Then shift-drag with left-right movement, it rotates about the screen
up-down axis while looking at rotate=[] at the bottom of the screen, Y
changes. Then Reset-view, ie diagonal, do the same drag.

> The viewport's depth axis is Y, not Z.

Do View-top, then move mouse to bottom/right corner, drag toward
bottom-left,
ie rotate around depth, see rotate=[], Z changes.

> X is pitch, Y is roll, Z is yaw.

Like graph paper,
left-right is the X-axis, thus rotate-X = pitch,
up/down is the Y-axis, rotate-Y = roll,
top/bottom is Z-axis, rotate-Z should = viewport yaw,
but changing $vpr Z does not yaw the viewport, it yaws the 3D-space Z-axis.

Play with that code & customizer, select only Rotate_Z, click view-left.



-----
OpenSCAD Admin - email* me if you need anything,  or if I've done something stupid...

* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

JordanBrown
In reply to this post by MichaelAtOz
On 12/8/2020 3:18 PM, MichaelAtOz wrote:
You would expect Z to then be AROUND the viewport depth axis, but it rotates
around the 3d-space X/Y plain.

So far it seems totally consistent to me.

Each rotation rotates the object around the specified axis - whichever way that axis points right now.  (But first offset by $vpt.)

The key thing is that if you have [ rx, 0, rz ] it *first* rotates around the X axis and *then* rotates around the Z axis.

Since rotating around the X axis moves the Z axis off vertical, rotating around Z causes the X axis line to move on the screen.

I think that's the effect that Bruce is talking about.

Bruce:  if you keep the Y and Z rotations zero, I think you'll see that rotating around X works exactly as you expect.  Similarly, if you keep the Z rotation zero, rotating around Y works as you expect (even if X rotation is non-zero).

I suspect that it is a deep philosophical question whether what is happening is that the universe is turning (around $vpt) while the camera remains still, or if the camera is orbiting $vpt while continuing to point at it.

What it definitely *isn't* is turning the camera.  The camera always points at $vpt.

I think.



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

JordanBrown
On 12/8/2020 5:32 PM, Jordan Brown wrote:
On 12/8/2020 3:18 PM, MichaelAtOz wrote:
You would expect Z to then be AROUND the viewport depth axis, but it rotates
around the 3d-space X/Y plain.

So far it seems totally consistent to me.

Each rotation rotates the object around the specified axis - whichever way that axis points right now.  (But first offset by $vpt.)

The key thing is that if you have [ rx, 0, rz ] it *first* rotates around the X axis and *then* rotates around the Z axis.

Since rotating around the X axis moves the Z axis off vertical, rotating around Z causes the X axis line to move on the screen.

... moves the Z axis off of *screen* vertical ...


I think that's the effect that Bruce is talking about.

Bruce:  if you keep the Y and Z rotations zero, I think you'll see that rotating around X works exactly as you expect.  Similarly, if you keep the Z rotation zero, rotating around Y works as you expect (even if X rotation is non-zero).

I suspect that it is a deep philosophical question whether what is happening is that the universe is turning (around $vpt) while the camera remains still, or if the camera is orbiting $vpt while continuing to point at it.

What it definitely *isn't* is turning the camera.  The camera always points at $vpt.

I think.



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

OpenSCAD mailing list-2
In reply to this post by MichaelAtOz
Yes MichaelAtOz,

That is a good demo of what I am getting at.

Bruce




--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Unexpected $vpr behavior

OpenSCAD mailing list-2
In reply to this post by MichaelAtOz
Just testing to see if my username shows up after enabling mail options...



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org