How to calculate angle from velocity of moving pivot (pendulum)? - physics

I am trying to simulate pendulum with moving pivot in processing.js. My question is, how to calculate angle at which my pendulum swing (while pivot is moving), based on pivot velocity? I searched all the web, but there angle is always known in equations. Is there any equation to calculate this from moving?

Related

Bezier curve, get consistent points on axis?

So I have a bezier curve >
Now, I would like to get a y point, value every says, 0.01 value on x-axis.
As far as I know, there is no method to "find Y given X" using bezier.
So I have to subdivide it into flat straight chunks and then get... "somehow" nearest chunk value as an approximation?
So my question is, how can I... "equally" subdivide the bezier curve so that chunk distance is more equal on... x-axis?
Right now the chunk distancing that I get is quite... "random" using https://en.wikipedia.org/wiki/B%C3%A9zier_curve as my current algo.
Regards
Dariusz
As far as I know, there is no method to "find Y given X" using bezier.
Then you probably need to look for "finding Y given X" a bit more =) https://pomax.github.io/bezierinfo/#yforx
As for the result you want, with regularly spaced intervals based on distance along the curve is the general problem of reparameterizing the curve for distance rather than time., and it's a hard problem for quadratic, and literally impossible problem for higher order Beziers.
So instead of trying to do that, what we typically do is just build a lookup table by sampling the curve, storing those "t maps to x/y and distance d along the curve", and then we use that combined with interpolation to get good-enough approximate coordinates (e.g. sub-sub-pixel accurate) rather than mathematically perfect coordinates. https://pomax.github.io/bezierinfo/#tracing

what kind of moving average will be drawn when we use (mpl.finance mav) function

My question is when we use mplfinance mpf.plot function to draw candlestick and use the mav function to draw the moving average. What kind of moving average it is? Is it Exponential moving average or simple moving average?
fig, axlist = mpf.plot(daily,type='candle',mav=(20),volume=True, style='blueskies',returnfig=True)
mplfinance mpf.plot(data,...,mav=...) does a simple moving average (although it also allows for a shift in the moving average).
The code for the moving average is here.
Specifically, the actual calulation is on this line of code.
It should not be very difficult to modify the code to allow for other types of moving averages, particually if you want to contribute.
That said, in the menatime, alternative moving averages can be calulated externally and plotted with mpf.make_addplot().

Path mapping using VectorNav VN100 IMU to map a route between two GPS coordinates

I'm trying to use a VectorNav VN100 IMU to map a path through an underground tunnel (GPS denied environment) and am wondering what is the best approach to take to do this.
I get lots of data points from the VN100 these include: orientation/pose (Euler angles, quaternions), and acceleration and gyroscope values in three dimensions. The acceleration and gyro values are given in raw and filtered formats where filtered outputs have been filtered using an onboard Kalman filter.
In addition to IMU measurements I also measure GPS-RTK coordinates in three dimensions at the start and end-points of the tunnel.
How should I approach this mapping problem? I'm quite new to this area and do not know how to extract position from the acceleration and orientation data. I know acceleration can be integrated once to give velocity and that in turn can be integrated again to get position but how do I combine this data together with orientation data (quaternions) to get the path?
In robotics, Mapping means representing the environment using perception sensor (like 2D,3D laser or Cameras).
Once you got the map, it can be used by robot to know its location(Localization). Map is also used for find a path between locations to move from one place to another place(Path planning).
In your case you need a perception sensor to get the better location estimation. With only IMU you can track the position using Extended Kalman filter(EKF) but it drifts quickly.
Robot Operating System has EKF implementation you can refer it.
Ok so I came across a solution that gets me somewhat closer to my goal of finding the path travelled underground, although it is by no means the final solution I'm posting my algorithm here in the hopes that it helps someone else.
My method is as follows:
Rotate the Acceleration vector A = [Ax, Ay, Az] output by the VectorNav VN100 into the North, East, Down frame by multiplying by the quaternion VectorNav output Q = [q0, q1, q2, q3]. How to multiply a vector by a quaternion is outlined in this other post.
Basically you take the acceleration vector and add a fourth component on to the end of it to act as the scalar term, then multiply by the quaternion and it's conjugate (N.B. the scalar terms in both matrices should be in the same position, in this case the scalar quaternion term is the first term, so therefore a zero scalar term should be added on to the start of the acceleration vector) e.g. A = [0,Ax,Ay,Az]. Then perform the following multiplication:
A_ned = Q A Q*
where Q* is the complex conjugate of the quaternion (i, j, and k terms are negated).
Integrate the rotated acceleration vector to get the velocity vector: V_ned
Integrate the Velocity vector to get the position in north, east, down: R_ned
There is substantial drift in the velocity and position due to sensor bias which causes drift. This can be corrected for somewhat if we know the start and end velocity and start and end positions. In this case the start and end velocities were zero so I used this to correct the drift in the velocity vector.
Uncorrected Velocity
Corrected Velocity
My final comparison between IMU position vs GPS is shown here (read: there's still a long way to go).
GPS-RTK data vs VectorNav IMU data
Now I just need to come up with a sensor fusion algorithm to try to improve the position estimation...

Calculating distance in m in xyz between GPS coordinates that are close together

I have a set of GPS Coordinates and I want to find the speed required for a UAV to travel between them. Doing this by calculating distance in x y z and then dividing by time to travel - m/s.
I know the great circle distance but I assume this will be incorrect since they are all relatively close together(within 10m)?
Is there an accurate way to do this?
For small distances you can use the haversine formula without a relevant loss of accuracy in comparison to Vincenty's f.e. Plus, it's designed to be accurate for very small distances. This can be read up here if you are interested.
You can do this by converting lat/long/alt into XYZ format for both points. Then, figure out the rotation angles to move one of those points (usually, the oldest point) so that it would be at lat=0 long=0 alt=0. Rotate the second position report (the newest point) by the same rotation angles. If you do it all correctly, you will find X equals the east offset, Y equals the north offset, and Z equals the up offset. You can use Pythagorean theorm with X and Y (north and east) offsets to determine the horizontal distance traveled. Normally, you just ignore the altitude differences and work with horizontal data only.
All of this assumes you are using accurate formulas to convert lat/lon/alt into XYZ. It also assumes you have enough precision in the lat/lon/alt values to be accurate. Approximations are not good if you want good results. Normally, you need about 6 decimal digits of precision in lat/lon values to compute positions down to the meter level of accuracy.
Keep in mind that this method doesn't work very well if you haven't moved far (greater than about 10 or 20 meters, more is better). There is enough noise in the GPS position reports that you are going to get jumpy velocity values that you will need to further filter to get good accuracy. The math approach isn't the problem here, it's the inherent noise in the GPS position reports. When you have good reports, you will get good velocity.
A GPS receiver doesn't normally use this approach to know velocity. It looks at the way doppler values change for each satellite and factor in current position to know what the velocity is. This works reasonably well when the vehicle is moving. It is a much faster way to detect changes in velocity (for instance, to release a position clamp). The normal user doesn't have access to the internal doppler values and the math gets very complicated, so it's not something you can do.

formulas in Projectile Motion?

how can i calculate angle to reach particular height?
suppose i want height 320.time is increasing as 0.1.
i am using h = (u sin(angle))^2 / 2g;
where can i put the time?
The inverse of the sin() function is called the arcsine, or sin-1 in mathematical notation. In many programming languages, it's available as asin().
From my answer to your previous question:
Where y is the height you want to reach (320 in this case), and assuming you're starting at y=0:
angle = arctan( 2*y / x )
where x is the distance on the X-AXIS between your starting point and the point where you want to reach that height, which is necessary in order to specify an angle.
If you really want me to, I can derive this one for you, but it follows directly from my answer to your previous question.
Also (since I can't comment answers yet I'm saying this here), you may be having issues getting an angle "less than 1" because you're trying to use degrees instead of radians. Many math libraries work in radians, so convert your angles.