I am trying to find angle of yellow line from center of circle. I know circle radius, red and blue point coordinates and angle between red and yellow lines.
What kind of formula should I use?
Think the situation is as follows:
Points R and B are given, as well as angle θ. What is asked for is angle φ.
I place a coordinate system on the center of the circle and expressed R in polar coordinates
d = sqrt( (x_R-x_B)^2 + (y_R-y_B)^2 )
ψ = atan2( (y_R-y_B), (x_R-x_B) )
Then use the law of cosines to find l
l = sqrt(r^2 + d^2 -2*r*d*cos(θ))
Now to find φ and ψ we use the following two equations
d*cos(ψ) = r*cos(φ)-l*cos(θ-φ)
d*sin(ψ) = r*sin(φ)+l*sin(θ-φ)
This is where I am stuck now.
Assuming the following are known:
side BC = a
radius CA = b
angle ∡BAC = α
It follows from the law of sines that sin ∡ABC = AC sin ∡BAC / BC = b sin α / a. The right-hand side is a known quantity, so the equation can be solved for ∡ABC then the third angle of △ABC is ∡BCA = π - α - ∡ABC. This gives the angle between the yellow line and the known segment BC.
Yes, it is possible.
Assuming the vector length is the same, you could define the first point as the origin (0,0).
Then describe the first vector in polar coordinates, (r, \displaystyle \thetaθ), where \displaystyle r = \sqrt{x_{1 }^{2} + y_{1 }^{2}}r=
x
1
2
+y
1
2
and \displaystyle \thetaθ = \displaystyle arctan(y_{1 }/x_{1 })arctan(y
1
/x
1
).
Then create the second vector by adding k degrees to \displaystyle \thetaθ: \displaystyle \theta_{2 }θ
2
= \displaystyle \thetaθ + k
Then convert from polar coordinates back to rectangular coordinates--if you need them that way:
\displaystyle x_{2 } = r cos(\theta_{2 })x
2
=rcos(θ
2
) and
\displaystyle y_{2 } = r sin(\theta_{2 })y
2
=rsin(θ
2
)
Related
I need to calculate a 3D circle center point from 2 points(3D) and arc angle (plane normal is also known).
I searched it with Google but I think my English is not good enough to search properly. Anyone know the calculations to do this?
We have points A, B, normal N, angle Fi.
Calculate difference vector (arc chord) and middle point
AB = B - A
M = (A + B) / 2
Calculate vector F perpendicular to AB and N using vector product and normalize it
F = AB x N
uF = F / len(F)
We know that circle center C lies on the ray from point M with direction F (with parameter t equal to apothem CM length (center-chord distance))
C = M + t * uF
What should be t value? We can express t through right triangle AMC parameters
tan(Fi/2) = 0.5*len(AB) / t
So finally center is
C = M + uF * 0.5*len(AB) / tan(Fi/2)
Note that center C is not unique because we don't know arc direction (just change sign before uF in the last formula and get mirror point C' against chord)
I have a polygon defined by n points and a polygon normal.
Now I want to get the plane of the polygon defined by
a plane normal=(nx,ny,nz)
and a constant d (distance from the origin to the plane).
The plane normal is equal to the polygon normal, but how can I calculate d?
desired plane equation nx*x+ny*y+nz*z+d=0.0
Take any point p=(px, py, pz) on the plane and plug it into the equation to obtain d.
So if your equation is
nx·x + ny·y + nz·z + d = 0
then you get
d = − (nx·px + ny·py + nz·pz).
Another common formulation is using d as the right hand side of the equation, in which case you get the reverse sign. I.e. for the equation
nx·x + ny·y + nz·z = d
you get
d = nx·px + ny·py + nz·pz.
I have a point in 3d P(x,y,z) and a plane of view Ax+By+Cz+d=0 . A point in plane is E.Now i want to project that 3d point to that plane and get 2d coordinates of the projected point relative to the point E.
P(x,y,z) = 3d point which i want to project on the plane.
Plane Ax + By + Cz + d = 0 , so normal n = (A,B,C)
E(ex,ey,ez) = A point in plane ( eye pos of camera )
What i am doing right now is to get nearest point in plane from point P.then i subtract that point to E.I suspect that this is right ???
please help me.Thanks.
The closest point is along the normal to the plane. So define a point Q that is offset from P along that normal.
Q = P - n*t
Then solve for t that puts Q in the plane:
dot(Q,n) + d = 0
dot(P-n*t,n) + d = 0
dot(P,n) - t*dot(n,n) = -d
t = (dot(P,n)+d)/dot(n,n)
Where dot((x1,y1,z1),(x2,y2,z2)) = x1*x2 + y1*y2 + z1*z2
You get a point on the plane as p0 = (0, 0, -d/C). I assume the normal has unit length.
The part of p in the same direction as n is dot(p-n0, n) * n + p0, so the projection is p - dot(p-p0,n)*n.
If you want some coordinates on the plane, you have to provide a basis/coordinate system. Eg two linear independent vectors which span the plane. The coordinates depend on these basis vectors.
I tried using a raycasting-style function to do it but can't get any maintainable results. I'm trying to calculate the intersection between two tangents on one circle. This picture should help explain:
I've googled + searched stackoverflow about this problem but can't find anything similar to this problem. Any help?
Well, if your variables are:
C = (cx, cy) - Circle center
A = (x1, y1) - Tangent point 1
B = (x2, y2) - Tangent point 2
The lines from the circle center to the two points A and B are CA = A - C and CB = B - C respectively.
You know that a tangent is perpendicular to the line from the center. In 2D, to get a line perpendicular to a vector (x, y) you just take (y, -x) (or (-y, x))
So your two (parametric) tangent lines are:
L1(u) = A + u * (CA.y, -CA.x)
= (A.x + u * CA.y, A.y - u * CA.x)
L2(v) = B + v * (CB.y, -CB.x)
= (B.x + v * CB.y, B.x - v * CB.x)
Then to calculate the intersection of two lines you just need to use standard intersection tests.
The answer by Peter Alexander assumes that you know the center of the circle, which is not obvious from your figure http://oi54.tinypic.com/e6y62f.jpg.
Here is a solution without knowing the center:
The point C (in your figure) is the intersection of the tangent at A(x, y) with the line L perpendicular to AB, cutting AB into halves. A parametric equation for the line L can be derived as follows:
The middle point of AB is M = ((x+x2)/2, (y+y2)/2), where B(x2, y2). The vector perpendicular to AB is N = (y2-y, x-x2). The vector equation of the line L is hence
L(t) = M + t N, where t is a real number.
I have a 3D Plane defined by two 3D Vectors:
P = a Point which lies on the Plane
N = The Plane's surface Normal
And I want to calculate any vector that lies on the plane.
Take any vector, v, not parallel to N, its vector cross product with N ( w1 = v x N ) is a vector that is parallel to the plane.
You can also take w2 = v - N (v.N)/(N.N) which is the projection of v into plane.
A point in the plane can then be given by x = P + a w, In fact all points in the plane can be expressed as
x = P + a w2 + b ( w2 x N )
So long as the v from which w2 is "suitable".. cant remember the exact conditions and too lazy to work it out ;)
If you want to determine if a point lies in the plane rather than find a point in the plane, you can use
x.N = P.N
for all x in the plane.
If N = (xn, yn, zn) and P = (xp, yp, zp), then the plane's equation is given by:
(x-xp, y-yp, z-zp) * (xn, yn, zn) = 0
where (x, y, z) is any point of the plane and * denotes the inner product.
And I want to calculate any vector
that lies on the plane.
If I understand correctly You need to check if point belongs to the plane?
http://en.wikipedia.org/wiki/Plane_%28geometry%29
You mast check if this equation: nx(x − x0) + ny(y − y0) + nz(z − z0) = 0 is true for your point.
where: [nx,ny,nz] is normal vector,[x0,y0,z0] is given point, [x,y,z] is point you are checking.
//edit
Now I'm understand Your question. You need two linearly independent vectors that are the planes base. Sow You need to fallow Michael Anderson answerer but you must add second vector and use combination of that vectors. More: http://en.wikipedia.org/wiki/Basis_%28linear_algebra%29