plot3d - make the perspective of front and back planes equal - r

I am migrating from gnuplot to R plotting.
In gnuplot when a 3d is rotated the front and back of the view line up, making the appearance of 2d plot.
In plot3d() the back plane appears narrower than the front plane of the view. So , it appears like there is a distance view (tunnel vision).
R plot3d showing narrowing of view:
gnuplot showing a 3d rotated so the front and back are one:
In my plot3d() the xyz axis are all set to 30 - a cube.
The question becomes: does plot3d() have way to not have a narrowing of the perspective ?
If the answer is 'no' - OK.
If the answer is 'yes' - just point me to a link or the documentation.

I suspect you are looking for an isometric perspective; try par3d(FOV=0). From ?par3d:
‘FOV’ real. The field of view, from 0 to 179 degrees. This
controls the degree of parallax in the perspective view.
Isometric perspective corresponds to ‘FOV = 0’.

Related

How to calculate a random point inside a cube

I'm trying to figure out the math to find a random point inside a cube.
I have something small but it can't take into account the rotation of the cube.
Here are some images of my results.
Here you can see the cube is rotated to some degree but when I generate some points it retains the shape as if the cube was normal (I think the term is called axis aligned but I'm not sure).
I'm using a Vector to represent the extent of the cube but for the life of me I can't figure out how to get the points to follow it when it's rotated.
Can someone point me in the right direction as to how I would do this?
EDIT1:
Now its misaligned and it goes even weirder when I rotate it sideways.
Can someone walk me through it from the beginning? I think my base line math is all wrong to begin with.
Generate the points in the straight position then apply the rotation (also check the origin of the coordinates).

Rotate around z-axis only in plotly

I'm trying out plotly for interactive 3D plotting, and it's great, but I found the 3D rotated plots a bit annoying, since by default the rotation is around all x, y and z axes (similarly as in e.g. Google Maps).
Is it possible to rotate only around the z-axis and just pan the camera view up and down?
So basically now the rotation is SO(3) in Lie group terms. I'd prefer at least an option to use SO(2)*R.
May 27 2015 EDIT
Plotly 3D graph interact in a new turntable mode of rotation.
We made this the default. Try it on any 3D graph.
Original answer
At the moment, Plotly 3D graphs only support one mode of rotation, as you described.
That said, adding a second "simple" mode of rotation is on our short term road map.
In the meantime, I suggest using the "back to default" and "back to last save" buttons in the modebar
if ever your graph gets lost in rotation.

Find point in 3D plane

I have four points in a 3D space, example:
(0,0,1)
(1,0,1)
(1,0,2)
(0,0,2)
Then I have a 2D position on that square plane:
x = 0.5
y = 0.5
I need to find out the 3D space point of that position in the plane. In this example it's easy: (0.5,0,1.5), because Y is zero. But imagine that Y was not zero (and not all the same), that the plane is leaning in some direction. How would I calculate the point in that case?
I imagine this should be a pretty easy thing to solve, but I can't figure it out. Please answer in programming terms and not in straight math terms, if possible.
Update with image: The gray plane (made out of two triangles) are the real one actually existing. I create a non-existing plane on top of this, the ABCD corners are exactly the same, however it doesn't slope. What I need to do is project a pixel (blue one in example) from the non-existing plane to the existing plane. It will be in the exact same location, except that it has gained a Y value from the sloping plane.
(couldn't actually make the image appear because i need 10 reputation to show it, wtf?)
What I've been able to work out so far on my own is which one of the two triangles to use in the gray plane and the normal of triangle. I basically just need to figure out how I can project the pixel.
Figured it out mostly thanks to http://gamedeveloperjourney.blogspot.com/2009/04/point-plane-collision-detection.html
Made me realize I had to verify the normal a bit closer, turns out my plane's grid was being rendered a little different than the actual coordinates for the verticles. No wonder this was so hard to get right! The pixel was projected correctly but rendered incorrectly.

3d flipping/rotation in flex-actionscript 3

I want to make an flipping card object which has three sides, basic requirement is like below
as in image, I want to rotate from horizontal center of card but I can not find any way to change orientation of rotation except put card in an container and set its x to -(width/2) I am using appendRotation method after setting its z component to 1 and everytime appending -5 rotation on Y axis.
How to achieve this elegantly? any suggestions appreciated...
For a simple two sided 3D object using the native 3D capabilities of the Flash Player, check out this handy class: http://blog.soulwire.co.uk/code/open-source/two-sided-planes-in-flash-player-10
I'd suggest looking at Papervision 3d or away 3D and make a 2 sided plane, one side of the plane being a view stack that contains views 1 and 2.

Project a grid in screenspace on the world xz plane

I want to project a grid on the xz-plane like shown here:
To do that, I created a vertex grid with x and z range [-1|1]. In the shader I multiply the xz screen coordinate of a vertex with the inverse of the View-Projection matrix. Then I want to adjust the height, depending on the new world xz coordinates and finally I transform these coordinates back to screenspace by multiplying them with the View-Projection matrix.
I dont know why, but I get a very strange plane shown on the screen. Are the mathematical oprations I use correct?
The grid that you initially create, is that in projection space or actual screen co-ords? It sounds like it is in projection space since you only transform it with the inverse of the view-projection matrix to get into world co-ords. I think you need to include the "Window" matrix too i.e. transform them by the inverse of the View-Projection-Window matrix (and similarly on the way back to screen co-ords).
Edit:
I'm probably not understanding exactly what it is you're trying to do so here's some questions back. :)
Are you trying to take the grid that's shown in the screenshot in your question and project that onto world z-x co-ordinates? If so, then why do you start with a grid of z-x values? Also, if you apply an inverse view matrix to those then surely you would end up with a line since the camera looks along z although your second screenshots show that you are getting a plane. I'm a bit confused.

Resources