As shown in the figure, I need to find azimuth and elevation of point P wrt to Camera 2. Point P(a,b,c) has co-ordinates defined with respect to Camera 1 (X,Y,Z) with a direction of view vector (x,y,z) as the origin which is distance (d) vertically below the Camera 2 (both cameras are in the same plane). I can find the azimuth/elevation using How to calculate azimut & elevation relative to a camera direction of view in 3D ...? for point P with respect to Camera 1 but I want to find the azimuth/elevation wrt Camera 2. I am confused about how should I do this?
If add 'd' distance to Camera 1 co-ordinates to get Camera 2 co-ordinates (X,Y+d,Z), keeping the direction of view vector same (as both Cameras are in same plane) and Point P same, perform the same calculation for Camera 2. It gives out incorrect results. How do I do this for Camera 2?
Projection in Image Planes:
Related
I'm trying to work out whether a point is inside an ellipsoid cone formed between a point and a circle in 3D space. The cone is ellipsoid because the point is not perpendicular to the centre of the circle. See diagram below:
So I know:
The position of the point forming the apex of the cone: x
The location of the centre of the circle: c
The radius of the circle: r
The locations of various points I want to determine if they are inside the cone: y, z
Here is a top view of the same diagram:
I do not care about the base of the cone - I want points contained within the cone stretched effectively to infinity.
I've found formulae for working out whether a point is within an ellipsoid cone given the major/minor axis, but having difficulty working out how to do it when the ellipsoid cone is formed from a circle at an angle.
Thanks for any help!
With a conic you could probably determine distance from the axis and a semi major and minor and compute it directly.
Harder is some arbitrary shape.
If the cone has the point in the Z Axis direction, and you know a point in XYZ... then you should be able to draw an ellipse at that particular Z level. Maybe draw it with 360 segments.
Once you have your point and your ellipse, then you can test ellipse segment to see if there is an intersection in X & Y.
Imaging a circle at 0,0,0 with radius 1. And a point at 0,0,0 there are 2Y intersections at +/- 90 degrees and 2 X intersections happening at 0 and 180
If the point is at 2,0,0 you still have 2 intersections in X but they are to the left, and you want one to the left and one to the right.
Zero intersections mean. That you are outside the hoop.
Repeat across the 360 segments and determine how to handle points "on a line" and how close "on" is.
I have rectangle with known base and height. I need coordinates of points on rectangle perimeter which is obtained by drawing lines from the center of base after every known degree (Say 1 degree) for the range of 0 -180 degree.
To get my question clearly i have attached image below. Kindly have a look.
Clues for a possible approach:
Find x-coordinate of intersection of ray with angle Theta and top edge of rectangle (note special cases Theta = 0, Theta = Pi)
If this coordinate lies outside of rectangle, find y-coordinate of intersection of ray and vertical edge (choose right one depending on angle)
I am working on a ray tracer and I got around to adding cylinders to the scene. The point I am stuck at is finding the surface normal vector in the point the ray hits. I need this to be able to do the diffuse lighting. What I have at this point is the 3d point where the camera ray hits the cylinder and the actual cylinder which is defined with a point on the central axis, the vector representing the direction of the axis and the radius. So to sum up my question, how do I find the normal vector in a point having the cylinder hit point, the radius, a point on its axis and the direction vector of the axis?
The cylinder normal vector starts at the centerline of the cylinder at the same z-height of the point where the ray intersects the cylinder, ends at the radial point of intersection. Normalize it and you have your unit normal vector.
If the cylinder centerline is not along the global z-direction of the scene you'll have to transform to cylinder coordinates, calculate the normal vector, and transform that back to global coordinates.
There are three possible situations:
the hit_pt is on the TOP CAP of the cylinder:
if (length(hit_pt - cy.top_center) < cy.radius)
surface_normal = cy.ori;
the hit_pt is on the BOTTOM CAP of the cylinder:
if (length(hit_pt - cy.bottom_center) < cy.radius)
surface_normal = -1 * cy.ori;
the hit_pt is on the SIDE of the cylinder. We can use dot product to find the point 'pt' on the center line of the cylinder, so that the vector (hit_pt - pt) is orthogonal to the cylinder's orientation.
t = dot((hit_pt - cy.bottom_center), cy.ori); // cy.ori should be normalized and so has the length of 1.
pt = cy.bottom_center + t * cy.ori;
surface_normal = normalize(hit_pt - pt)));
Given a geodetic location on the earth, I'm trying to find the normal vector to the surface at that point in ECEF coordinates. I've found the equations to convert from geodetic to ECEF (a vector from the center of the earth to the point) and vice verse, but I'm not quite sure how to find the normal vector. Thanks!
Any vector on the earth surface is perpendicular to the earth radius (vector from the center of the earth to the point). Tangent is always normal to the radius-vector to the point of tangency.
finding normal vector:
cross product
cross product returns vector perpendicular to its operands so:
take your point A and 2 close points to it B,C (not on single line)
so you got geodetic position A(lon,lat) so let B(lon+d,lat) and C(lon,lat+d)
convert A,B,C to ECEF or Cartessian
create vectors u=B-A , v=C-A
normal = cross(u,v);
you should normalize the normal vector to unit size normal=normal/|normal|
this approach works on any kind of surface (not just for sphere and ellipsoid)
the smaller the d is the more precise normal you get (but must be d>0)
sphere
normal to any surface point A on a sphere with center C is easy
because normal lies on line going through the point A and center C
both points should be in ECEF or Cartessian
normal=A-C;
normalize if your sphere is not with radius=1.0
normal=normal/|normal|
if you have ellipsoid very close to sphere and do not need extreme precision you can compute the normal this way too
if you have geodetic(lon,lat,alt) to ECEF or Cartessian equations at disposal
then normal vector points up so:
let A(lon,lat,alt) be your point
let B(lon,lat,alt+d) be point a bit above A
let d=1 so the points are distant 1 unit between each other so:
convert A,B to ECEF or Cartessian
normal=B-A
as d=1 you do nt need to normalize
[notes]
see NEH local North,East,Height(or altitude) coordinate system it might interest you too
I have a list of 3D points. I know they are all coplanar. I have the center that I want to sort them around and the normal to the plane on which the points and the center lie. How can I test if one point is right (or left) of another point?
I understand how to do it in 2D. Sort points in clockwise order? explains how to compare 2d points. So I think I need to somehow covert all the points and the center to local 2d plane coordinates. How can I do that? Is it the most efficient way to solve this problem?
//from link:
// a and b are points
//center is the center around which to determine order
//int num = (a.x-center.x) * (b.y-center.y) - (b.x - center.x) * (a.y - center.y);
//if num=0 then they're on the same line
//if num <0 or num>0 then a is to the left or right of b
How would I adapt this to handle 3d coplanar points?
There's no need to convert everything to 2D.
You have the center C and the normal n. To determine whether point B is clockwise or counterclockwise from point A, calculate dot(n, cross(A-C, B-C)). If the result is positive, B is counterclockwise from A; if it's negative, B is clockwise from A.