Gimbal Lock how does it happen? - graphics

So I searched on the net and I'm having some problems imagining how the
gimbal-lock occurs. According to what i saw, it occurs when 2 or more axes align losing a degree of freedom but I can't imagine how will the axes even begin to align?
I mean, when i rotate an object around x-axis (for example) doesn't the y and z axes rotate with the X-axis to remain perpendicular? How are they gonna align? Similarly whenever i rotate around Y or Z axis the other 2 axis rotate together and remain perpendicular don't they?
To get a more clear view what I am having problem imagining, check this video.
At 5:05
https://youtu.be/Mm8tzzfy1Uw?t=305
You'll see when he rotates around the X axis the green and the blue rings remain there where as according to my imagination the green (Y) and blue (Z) axes should have rotated. I don't understand why the rings are still aligned with the world axis?

Gimbal Lock.
Gimbal lock does not lock an axis but rather it locks the action of the gyro to move freely in all three axis.
The gimbal's three axis, yaw outer ring (axis along up/down), pitch next ring in (axis along left/right), and roll the inner ring (axis along front/back). If you rotate the pitch ring 90 deg in either direction it will align the roll axis with the yaw axis and the gyro will act as if they are one.
The following image will help
Left. The Gimbal at start, red axis yaw, blue pitch, green roll. Then rotating around pitch 90deg (blue axis),the roll axis (green) is aligned with the yaw axis (red) and you have gimbal lock.

Related

What is the endpoint calculation in the Xiaolin Wu algorithm doing?

The Xiaolin Wu algorithm draws an anti-aliased line between two points. The points can be at sub-pixel, i.e. non-integer coordinates. I'll assume the reader is familiar with the algorithm and just recall the important features. We loop across the major (longer) axis of the line, let's say it's the x-axis, basically proceeding column-by-column. In each column we color two pixels. The computation is equivalent to this: place a 1x1 square centered on the line, at the point whose x coordinate is the center of the the given column of pixels. Let's call it S. If we think of each pixel as a 1x1 square in the plane, we now calculate the area of intersection between S and each of the two pixels it straddles, and use those areas as the intensities with which to color each pixel.
That's nice and clear, but what is going on with the calculations for the endpoints? Because the endpoints can be at non-integer positions, they have to be treated as a special case. Here's the pseudocode from the linked Wikipedia article for handling the first endpoint x0, y0:
// handle first endpoint
xend := round(x0)
yend := y0 + gradient * (xend - x0)
xgap := rfpart(x0 + 0.5)
xpxl1 := xend // this will be used in the main loop
ypxl1 := ipart(yend)
plot(ypxl1, xpxl1, rfpart(yend) * xgap)
plot(ypxl1+1, xpxl1, fpart(yend) * xgap)
I edited out the if (steep) condition, so this is the code for the case when the slope of the line is less than 1. rfpart is 1-fpart, and fpart is the fractional part. ipart is the integer part.
I just have no idea what this calculation is supposed to be doing, and I can't find any explanations online. I can see that yend is the y-coordinate of the line above xend, and xend is the x coordinate of the pixel that the starting point (x0, y0) is inside of. Why are we even bothering to calculate yend? It's as if we're extending the line until the nearest integer x-coordinate.
I realize that we're coloring both the pixel that the endpoint is in, and the pixel either immediately above or below it, using certain intensities. I just don't understand the logic behind where those intensities come from.
With the Xiaolin Wu algorithm (and sub-pixel rendering techniques in general) we imagine that the screen is a continuous geometric plane, and each pixel is a 1x1 square region of that plane. We identify the centers of the pixels as being the points with integer coordinates.
First, we find the so-called "major axis" of the line, the axis along which the line is longest. Let's say that it's the x axis. We now loop across each one-pixel-wide column that the line passes through. For each column, we find the point on the line which is at the center of that column, i.e. such that the x-axis is an integer. We imagine there's a 1x1 square centered at that point. That square will completely fill the width of that column and will overlap two different pixels. We color each of those pixels according to the area of the overlap between the square and the pixel.
For the endpoints, we do things slightly differently: we still draw a square centered at the place where the line crosses the centerline of the column, but we cut that square off in the horizontal direction at the endpoint of the line. This is illustrated below.
This is a zoomed-in view of four pixels. The black crosses represent the centers of those pixels, and the red line is the line we want to draw. The red circle (x0, y0) is the starting point for the line, the line should extend from that point off to the right.
You can see the grey squares centered on the red crosses. Each pixel is going to be colored according to the area of overlap with those squares. However, in the left-hand column, we cut-off the square at x-coordinate x0. In light grey you can see the entire square, but only the part in dark grey is used for the area calculation. There are probably other ways we could have handled the endpoints, for instance we could have shifted the dark grey region up a bit so it's vertically centered at the y-coordinate y0. Presumably it doesn't make much visible difference, and this is computationally efficient.
I've annotated the drawing using the names of variables from the pseudocode on Wikipedia.
The algorithm is approximate at endpoints. This is justified because exact computation would be fairly complex (and depend on the type of endpoint), for a result barely perceivable. What matters is aliasing along the segment.

How to represent orientation of rigid body in space with quaternions if roll is zero

I am trying to represent the orientation of a rigid body, say a pencil in 3 dimensional space with respect to fixed XYZ axes, originating at a fixed origin O. I am trying to visualize arriving at the quaternion representing the orientation of the pencil, by thinking in terms of the axis vector of the pencil's current orientation(i.e axis), and the roll on its own central lengthwise axis, (Following equation for quaternion from axis-angle representation is from Wikipedia).
Now as per my understanding if the roll of the pencil is zero, then the vector part of the quaternion vanishes, since sin(theta/2) shall become zero, and the resulting quaternion no longer has information of horizontal and vertical tilt with respect to the fixed axes. How I can describe the orientation of the pencil using quaternions in cases where the roll of the pencil is zero.
It is clearer if we imagine that the quaternion specifies the rotation from the default orientation of the pencil to its present orientation. One way of specifying this would be to assume that default orientation of the pencil is along the extrinsic X axis, with the default roll being zero when the label face is on the top. Now one possible way to describe the present orientation of the pencil is by the following three rotations:
Rotation about the Z, axis by the yaw angle
Rotation about the new Y axis, by the pitch angle
Rotation about the new X axis, by the roll
The combination of these three rotations, obtained by their quaternion product , will give us the quaternion of the pencil's present orientation, even if the roll, pitch or yaw is zero.

Check specific axis with quaternions

If I use euler angles, I'm aware of them having different ways to represent the same rotation but, at the same time, I need to be able to check the rotation progress in X axis. It starts, for instance, at rotation 15 degrees in X axis and I don't care about Y and Z. If I look at it after some movements of that object, maybe it shows that X axis is different although maybe X axis didn't move at all, this is because of euler angles. With quaternions this is not supposed to happen but I don't know how to check then, the progress in the rotation of one axis.

Flip X and Y axis on Excel custom chart

I've made a chart with Excel 2010's "Combo" option for chart type so I can plot two data series for the same depth points. The image below shows the default, which is very close to what I want - except I would like to have the axes flipped so that the current X axis, which is depth, is displayed as the Y axis and both primary and secondary current Y axes plot as X axes. In other words, I'd like to rotate the chart area by 90 degrees clockwise. The "Switch Row/Column" doesn't do what I want (or expect) and I'm running out of both ideas and patience. Is there an easy fix? Or a hard fix?
Here's the plot as-is:
And here's a dummy plot of the end goal made by rotating the image around in Paint, in case the picture makes it clearer:
Finally, as was pointed out in the comments, the whole thing looks goofy and might be better plotted as a bar graph with two bars. I tried this as well and came away almost all set - but the gray bars plot from left to right and the blue bars plot from right to left. Seems like it should be as simple as changing the "Plot Series On" option to Primary Axis for both, but this destroys the graph.
I looked around and I think this link has instructions for what you're looking for: https://superuser.com/questions/188064/excel-chart-with-two-x-axes-horizontal-possible

Rotate X,Y Coordinates from Bottom Right to Top left

I'm using NodeXL to plot a lot of points which are actual coordinates for cities.
The thing is that the way it's plotted now is that North America is on the Bottom Right but it should be on the top left like on a normal map.
It's like this for all of the points so pretty much I need to rotate the whole graph so that what's on the bottom right will be top left after transformation, and what's on the top right will be on the bottom left.
I have two columns with X and Y points as follows (for example):
X Y
6,238.2 9,896.0
6,141.9 9,896.0
I'm not sure the formula or Math behind this kind of rotation.
The graph is only positive so from (0,0) upward and outward to the right, there are no negative values on the x or y axis.
Could anyone help me out?
For the sake of an answer:
To quote #Tim Williams: Instead of plotting x and y plot (width-x) and (height-y)
Example:

Resources