Calculate time to reach top of the trajectory of a projectile - distance

I have below information like gravity, thrust, my initial x, y and initial velocities. How do I calculate
1. Time to reach the top of the projectile 2. Horizontal displacement during that time
"grav": 0.7,
"thrust": 10.5,
"me": {
"x": 0,
"y": 180,
"vx": 4,
"vy": 0
}
So far I have tried this formula to calculate vertical displacement (reference here)
For Horizontal displacement, I used t*vx0;

If initial vertixal velocity(vy) is zero, assuming gravity is on the y direction, then how is the object ever going to go up to reach the top?
Generally thrown objects reach the top when vy = 0 when t= vy/grav, and x position = t * vx.

Related

Unable to rotate around the Z axis in RealityKit / ARKit

I'm creating an app using RealityKit and I'm having trouble rotating an element around the Z axis.
The element is an eyelid - which is essentially a sphere cut in half. My hope is to update the Z axis so it rotates. But no matter what I do, it does not move at all.
I am able to successfully rotate it around the x and y axis. But the z-axis seems to be stuck.
robot.topLidL?.orientation = simd_mul(
simd_quatf(angle: deg2rad(-80 + (130 * eyeBlinkLeft)), axis: [1, 0, 0]), // this line handles the blinking as expected
simd_quatf(angle: deg2rad((130 * browLeft) - (60 * browInnerUp)), axis: [0, 0, 1])) // this should rotate the eyelid around the z axis but it does not move at all.
I get 0 movement at all around the z-axis. I confirmed that I am getting values from browLeft and browInnerUp. I looked at the assets in Reality Composer and all looks well. An interesting note is if I change the Z value in Reality Composer, I do see the rotation in Composer as I would expect. But when I hardcode that value in my code, it still doesn't change rotation position.
I also just tried
robot.topLidL?.orientation = simd_quatf(angle: deg2rad((130 * browLeft) - (60 * browInnerUp)), axis: [0, 0, 1])
and that doesn't work either. I even just hardcoded:
robot.topLidL?.orientation = simd_quatf(angle: deg2rad(50), axis: [0, 0, 1])
And even that didn't cause any change.
Simply put, I'm getting no movement at all around the z-axis.
Do you have any ideas why this might be the case?
Additional code:
private func deg2rad(_ value: Float) -> Float {
value * .pi / 180
}

Halcon - Flip coordinate system in pose

How can I flip the +/- direction of a single axis in a pose?
i want Z to go upwards, not downwards..
Thanks
If you want the z-axis goes upwards, you should apply a composing between that pose you're getting and another pose who has 180° (positive or negative) in the X or Y axis (any of both will work). If I try to emulate you posing, you should have something like next:
If you apply the composing I just said, you will get something like next:
The second image was achieved with a 180° rotation over X-Axis. The code was just:
create_pose (0, 0, 0, 0, 0, 0, 'Rp+T', 'gba', 'point', yourPose)
create_pose (0, 0, 0, 180, 0, 0, 'Rp+T', 'gba', 'point', transformationPose)
pose_compose (yourPose, transformationPose, transformedPose)
Remember, you would have 4 options for achieving the purpose of having Z-Axis upwards; +180° rotation in X-Axis, -180° rotation in X-Axis, +180° rotation in Y-Axis and -180° rotation in Y-Axis.

Ellipse - Finding the y-coordinate for a specific x co-ordinate

I was wondering if anyone can help me. I'm trying to modal an oval room, and the joists run parallel to one another at 400mm intervals, starting and finishing 200mm from the apexes of the oval. The central joist falls on the centre of the oval at (0,0).
So the oval is positioned at angle = 0, with a centre of (0,0). The major axis is 6000mm long in the x-direction and the minor axis is 3500mm long in the y-direction. The joists run in the y-direction too.
I need to find out the node for each joist along the outside edge of the ellipse. So obviously, I know the x values will be -2800, -2400, ..., 0, ..., 2000, 2400, 2800, and that the central joist will have one node at (0, 1750) and one at (0, -1750), but how can I find the y values for all the other x co-ordinates?
Many thanks.
p.s. In case you can't tell I have exceedinly rudimentary MATLAB skills.
It's convenient to work with semi-axes, denoted a and b below. The equation of ellipse is (x/a)^2+(y/b)^2=1, which gives two values of y, positive b*sqrt(1-(x./a)^2) and negative b*sqrt(1-(x./a)^2).
In MATLAB you can compute them this way:
a = 6000/2;
b = 3500/2;
x = -2800:400:2800;
yP = b.*sqrt(1-(x./a).^2);
yN = - yP;
So, yP contains the positive y-coordinates and yN contains negative y-coordinates.
The dots in front of arithmetic operations mean they are performed on vectors componentwise.

point projection into yx rotated plane

I want to simulate depth in a 2D space, If I have a point P1 I suppose that I need to project that given point P1 into a plane x axis rotated "theta" rads clockwise, to get P1'
It seems that P1'.x coord has to be the same as the P1.x and the P1'.y has to b shorter than P1.y. In a 3D world:
cosa = cos(theta)
sina = sin(theta)
P1'.x = P1.x
P1'.y = P1.y * cosa - P1.z * sina
P1'.z = P1.y * sina + P1.z * cosa
Is my P1.z = 0? I tried it and P1'.y = P1.y * cosa doesn't result as expected
Any response would be appreciated, Thanks!
EDIT: What I want, now I rotate camera and translate matrix
EDIT 2: an example of a single line with a start1 point and a end1 point (it's an horizontal line, result expected is a falling line to the "floor" as long as tilt angle increases)
I think it's a sign error or an offset needed (java canvas drawing (0,0) is at top-left), because my new line with a tilt of 0 is the one below of all and with a value of 90º the new line and the original one match
The calculation you are performing is correct if you would like to perform a rotation around the x axis clockwise. If you think of your line as a sheet of paper, a rotation of 0 degrees is you looking directly at the line.
For the example you have given the line is horizontal to the x axis. This will not change on rotation around the x axis (the line and the axis around which it is rotating are parallel to one another). As you rotate between 0 and 90 degrees the y co-ordinates of the line will decrease with P1.y*cos(theta) down to 0 at 90 degrees (think about the piece of paper we have been rotating around it's bottom edge, the x axis, at 90 degrees the paper is flat, and the y axis is perpendicular to the page, thus both edges of the page have the same y co-ordinate, both the side that is the "x-axis" and the opposite parallel side will have y=0).
Thus as you can see for your example this has worked correctly.
EDIT: The reason that multiplying by 90 degrees does not give an exactly zero answer is simply floating point rounding

Draw Camera Range with Postgis

i am working on some camera data. I have some points which consist of azimuth, angle, distance, and of course coordinate field attributes. In postgresql postgis I want to draw shapes like this with functions.
how can i draw this pink range shape?
at first should i draw 360 degree circle then extracting out of my shape... i dont know how?
I would create a circle around the point(x,y) with your radius distance, then use the info below to create a triangle that has a larger height than the radius.
Then using those two polygons do an ST_Intersection between the two geometries.
NOTE: This method only works if the angle is less than 180 degrees.
Note, that if you extend the outer edges and meet it with a 90 degree angle from the midpoint of your arc, you have a an angle, and an adjacent side. Now you can SOH CAH TOA!
Get Points B and C
Let point A = (x,y)
To get the top point:
point B = (x + radius, y + (r * tan(angle)))
to get the bottom point:
point C = (x + radius, y - (r * tan(angle)))
Rotate your triangle to you azimouth
Now that you have the triangle, you need to rotate it to your azimuth, with a pivot point of A. This means you need point A at the origin when you do the rotation. The rotation is the trickiest part. Its used in computer graphics all the time. (Actually, if you know OpenGL you could get it to do the rotation for you.)
NOTE: This method rotates counter-clockwise through an angle (theta) around the origin. You might have to adjust your azimuth accordingly.
First step: translate your triangle so that A (your original x,y) is at 0,0. Whatever you added/subtracted to x and y, do the same for the other two points.
(You need to translate it because you need point A to be at the origin)
Second step: Then rotate points B and C using a rotation matrix. More info here, but I'll give you the formula:
Your new point is (x', y')
Do this for points B and C.
Third step: Translate them back to the original place by adding or subtracting. If you subtracted x last time, add it this time.
Finally, use points {A,B,C} to create a triangle.
And then do a ST_Intersection(geom_circle,geom_triangle);
Because this takes a lot of calculations, it would be best to write a program that does all these calculations and then populates a table.
PostGIS supports curves, so one way to achieve this that might require less math on your behalf would be to do something like:
SELECT ST_GeomFromText('COMPOUNDCURVE((0 0, 0 10), CIRCULARSTRING(0 10, 7.071 7.071, 10 0), (10 0, 0 0))')
This describes a sector with an origin at 0,0, a radius of 10 degrees (geographic coordinates), and an opening angle of 45°.
Wrapping that with additional functions to convert it from a true curve into a LINESTRING, reduce the coordinate precision, and to transform it into WKT:
SELECT ST_AsText(ST_SnapToGrid(ST_CurveToLine(ST_GeomFromText('COMPOUNDCURVE((0 0, 0 10), CIRCULARSTRING(0 10, 7.071 7.071, 10 0), (10 0, 0 0))')), 0.01))
Gives:
This requires a few pieces of pre-computed information (the position of the centre, and the two adjacent vertices, and one other point on the edge of the segment) but it has the distinct advantage of actually producing a truly curved geometry. It also works with segments with opening angles greater than 180°.
A tip: the 7.071 x and y positions used in the example can be computed like this:
x = {radius} cos {angle} = 10 cos 45 ≈ 7.0171
y = {radius} sin {angle} = 10 sin 45 ≈ 7.0171
Corner cases: at the antimeridian, and at the poles.