I am learning some projection technique where we can project a 3d object like globe to a 2d. I have the 3d coordinates of points on the surface of sphere same as globe. Here is a reference where a globe can be projected on a plane using Stereo-graphic projection (https://en.wikipedia.org/wiki/Stereographic_projection) but this projection project the globe to a circle but i am trying to project sphere to a rectangle the same way as the globe is projected on a small paper (https://en.wikipedia.org/wiki/Mercator_projection).
For any projection, you're going to need to construct a map (no pun intended) from one coordinate system to the other.
For the mercator projection, the map can be a function of your sphere coordinate (azimuth & elevation) to rectangular coordinate (x & y).
Azimuth is your x coordinate. Elevation is your y coordinate.
Related
So, for anyone familiar with Google Maps, when you zoom, it does it around the cursor.
That is to say, the matrix transformation for such a zoom is as simple as:
TST^{-1}*x
Where T is the translation matrix representing the point of focus, S the scale matrix and x is any arbitrary point on the plane.
Now, I want to produce a similar effect with a spherical camera, think sketchfab.
When you zoom in and out, the camera needs to be translated so as to give a similar effect as the 2D zooming in Maps. To be more precise, given a fully composed MVP matrix, there exists a set of parallel planes that are parallel to the camera plane. Among those there exists a unique plane P that also contains the center of the current spherical camera.
Given that plane, there exists a point x, that is the unprojection of the current cursor position onto the camera plane.
If the center of the spherical camera is c then the direction from c to x is d = x - c.
And here's where my challenge comes. Zooming is implemented as just offsetting the camera radially from the center, given a change in zoom Delta, I need to find the translation vector u, colinear with d, that moves the center of the camera towards x, such that I get a similar visual effect as zooming in google maps.
Since I know this is a bit hard to parse I tried to make a diagram:
TL;DR
I want to offset a spherical camera towards the cursor when I zoom, how do i pick my translation vector?
I have a projected view of a 3D scene. The 2D points are computed by multiplying the 3D points in homogenous coordinates by a view matrix (which includes a translation and rotation) and a perspective matrix. I want to allow the user to move control points which describe the three axes, and update the rotation matrix based on this.
How do I compute the new rotation matrix given a change in projected 2D coordinates, assuming rotation around the origin? Solving for the position of the end of the single axis has a large degeneracy in the set of possible, but maybe solving for rotation in the axes perpendicular to the moved axis might work.
I'm trying to map a texture on a plane, I know the vertex coordinates for the texture, and the coordinates for the 4 vertices. Then how can I calculate the uv texture coordinates for the 4 vertices?
Here's a picture to show you what I'm trying to do,
The yellow with grid area is my texture, it is a square texture skewed into that shape. The green area is my plane that I want to map my texture on to. I know the vertex coordinates for point a, b, c, d, and point 1, 2, 3, 4.
For example, if my texture is placed like this
Those are the vertex coordinates for all the points. Then the uv coordinates for point a, b, c, d should be (-0.5f, -0.5f), (1.5f, -0.5f), (1.5f, 1.5f), (-0.5f, 1.5f)
But if the texture is skewed like the first picture, how can I calculate the uv coordinates for point a, b, c, d?
Where are you trying to do this CPU or GPU? Assuming CPU what you could do is project the vertices of your skewed plane onto the green plane. If you think of the green plane as a screen which has a camera and therefore associated view and projection matrices you could project each point onto its surface and then find the distance from the origin which is in your case in the middle of the green plane.
From your tags it looks like you are using OpenGL ES, are you using fixed function or shaders? What maths library do you use? GLM has glm::project and glm::unproject which are basically what you want here's a link to info about that.
Here's some general information on what you want to do, you basically want to project from 3D to 2D and then find the relative distances on your plane.
Hope that helps.
I have matrix A with size 5x3 which includes 3D (X,Y,Z) coordinates of some points and these points should be center of the spheres. and a vector B with size 5x1 which includes radius of each sphere. How can I plot the spheres around the points with defined radius in vector B and defined center in Matrix A?
Form Matlab docs
Description
The sphere function generates the x-, y-, and z-coordinates of a unit sphere for use with surf and mesh.
sphere generates a sphere consisting of 20-by-20 faces.
sphere(n) draws a surf plot of an n-by-n sphere in the current figure.
You'll need to scale those points by the radius of your sphere and translate them to the appropriate centre. Then plot them. 10 seconds of searching matlab documentation gave me the code to do that as well as to plot the spheres using the surf command.
surf
Create 3-D shaded surface plot
I'm trying to make a rubik cube game in webgl using three.js (you can try it here).
And I have problems to detect on witch axis I have to rotate my cube according the rotation of the cube. For instance, if the cube is in original position/rotation, if I want to rotate the left layer from down to up, I must make a rotation on the Y axis. But I rotate my cube 90 degrees on Y, I will have to rotate It on the Z axis to rotate my left layer from down to up.
I'm trying to find a way to get the correct rotation axis according the orientation of the cube.
For the moment I check witch vector of the axis of the rotation matrix of the cube is most parallel with the vector(0,1,0) if I want to move a front layer from down to up. But it do not works in edge cases like this for instance :
I guess there is some simple way to do that, but I'm not good enough in matrix and mathematical stuff :)
An AxisHelper can show the aixs of the scene which you could determine the orientation with.
var axishelper = new THREE.AxisHelper(40);
axishelper.position.y = 300;
scene.add(axishelper);
You could also log your cube and check the position and rotation properties with Chrome Developer Tools or Firebug.
You can store the orientation of each cube in its own 4x4 matrix (i.e. a "model" matrix) that tells you how to get from the cube's local coordinates to the world's coordinates. Now, since you want to rotate the cube around to an axis (i.e. vector) in world coordinates, you need to translate the axis into cube coordinates. This is exactly what the inverse of the model matrix yields.