Drawing a 3D circular arrow around a vector in MATLAB - matlab-figure

How do I create a circular arrow (in3D) in Matlab? As shown in the figure below, I have a vector v and want to draw a circular arrow around the vector to show the direction of Torque.

Related

How to "focus zoom" on a spherical camera?

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?

How does OpenGL map an image to a quadrilateral?

Image files are rectangular, yet in a 3D environment, a rectangle will appear as an irregular quadrilateral most of the time. Consider the following image (credit to this blog):
Given that:
you already know the four vertices of the green face
you have access to the image file as a 2D array of color values
you are drawing to a screen that is a 2D array of pixels
What is the algorithm that OpenGL uses for drawing the image onto the green face?
The algorithm is basically (if we ignore stuff like shaders for now):
break down the quadrilateral into two triangles
for each triangle, compute the projection onto the image plane
for each screen pixel covered by the projection of the triangle:
compute the texture coordinates by interpolation from the vertices for the position to which the pixel location corresponds on the triangle.
look up the texture image at the location that corresponds to the texture coordinates. Typically, some form of filtering is applied here.
you have found the color for your pixel

Inward offsetting a polygon recursively not requiring shape to be rigidly maintained

I start with a polygon, the blue contour. And then want to keep shrinking it inwards for say 4 depths. So in next iteration, i will get something like the green contour. Notice the shape of the polygon is maintained at least that is what i want to signify. This step can be easily done using Polygon Clipping and Offsetting Matlab wrapper by Emmett for the c++ Clipper Library by Angus.
However, in next step i want to shrink the green polygon further. However, the green polygon cannot be shrunk further while maintaining the shape of the green contour. So an algorithm should adaptively shrink to the magenta contour. That is what i have in mind. The motivation comes from drawing contours in maps. As long as the contour generated by the adaptive process looks realistic enough, i am not particular about what shape modification is done to get to the magenta contour.
I am working in Matlab and have looked for available stuff in this direction rather than coding something from scratch. Most inward offsetting tools for polygons maintain the shape while shrinking like this:
Suggestions to shrink a polygon to one single smaller polygon would be helpful. Shape modification is allowed.
The code used to create above image is:
p=[110 80;65 391;438 425;120 329];
ngon.x=p(:,1);
ngon.y=p(:,2);
scale=2^15;
ngon.x=int64(ngon.x*scale);
ngon.y=int64(ngon.y*scale);
outtie=clipper(ngon,ngon,1);% perform redundant self-intersection (required)
outtie.x=int64(outtie.x);
outtie.y=int64(outtie.y);
offset=clipper(outtie,-10*scale,1);
innie.x=offset.x/scale;
innie.y=offset.y/scale;
innie.x=[innie.x;innie.x(1)];
innie.y=[innie.y;innie.y(1)];
figure;
hold on
fill(ngon.x,ngon.y,'y')
plot(innie.x,innie.y,'r','linewidth',2)
To mex the clipper fucntion, please see here.

How to do an unfold / unwrap animation for cylinder shape in Three.js?

I try to do a cylinder unwrap animation for students to better understand the three surfaces of a cylinder.
It should look like this (found on youtube):
I can draw both circles (bottom and top) using THREE.CylinderGeometry
I can draw the lateral surface using THREE.CylinderGeometry without filling
But how do I do the outer blue animation of the unfolding "rectangle"?!
I have never done an animation with three.js before, so I would also need a suggestion here. Thanks.
The easiest way for this would be to use 3 meshes :
two CircleGeometry-ies for the circles
one custom Geometry for the unwrapping plane
The plane is actually two sets of vertices that represent a line wrapping/unwrapping over a circle. What controls the movement is that angles between each segments are tweened equally. With N being the number of segments, N being even for simplicity, you need to tween this angle from 0 (line state) to 360/N (circle state) on one side, and to -360/N on the other, beginning at the middle (360/N stands for 180/( N/2 ) on each side).
So in your custom Geometry() you define vertices and faces. Then you tween them with your favorite tweening library. End each update callback with geometry.verticesNeedUpdate=true;.
http://jsfiddle.net/2x4Lbvs0/7/

How to calculate a shape based on movement using opencv or other open source lib?

Here is the original image, the green colour is the background, and blue is the shape.
If my eye go closer to the shape, the blue square will be bigger like this:
If my eye go left, the shape will work like this:
I already know my eyes movement position, but how can I calculate what will the shape change? Any recommends? Thanks.
You need know the camera matrix http://en.wikipedia.org/wiki/Camera_matrix it will define the way which 3D coord will be projected to your sreen coordinates. If you know orientation of your camera, then you know 3d coords of object points relative to camera. Applying camera matrix transform to these 3d coords will give you 2d projections in you screen coordinates.

Resources