I have two points A=[ax,ay] and B=[bx,by] and i have angle in right triangle for CAB, for CBA (thats 90-ACB) and for ACB (90, right angle). Now i want to get coordinates [cx,cy] of point C (from two possibilities, i want that one C point which lies to left of orientated line segment form A to B).
How should I do it?
Calculate middle point D=(A+B)/2
Rotate vector DB on angle 2*CAB
(this is based on facts that centre of circumscribed circle is the middle of hypotenuse and that angle from centre is twice angle from A)
let's B-D=(dx,dy)
then C=D+(dx*cos2a+dy*sin2a,dy*cos2a-dx*sin2a)
Since you're given a side and two adjanced angles, what's left is to construct the the lines for the other two sides and intersect them.
Rotate the vector A->B by the angle BAC to the left, rotate the vector B->A by the angle ABC to the right and intersect.
To rotate a vector to the left, multiply it by the rotation matrix:
cos(a) sin(a)
-sin(a) cos(a)
To intersect two lines in their parametric forms in 2D, solve both parameters simultaneously, comparing the two components for both lines.
Related
I need to convert polar coordinates from decimal degrees to Cartesian points.
I know there are many formulas but I need a formula that uses only sine and cosine (no arcsine, arccosine), and that does not involve too many calculations.
The coordinates are all within a radius of 150km so it does not matter that it is not precise with coordinates far from each other.
Thanks!
If you have 2D polar coordinates with angle theta and radius r, then:
x = r * cos(theta)
y = r * sin(theta)
I have a data file with 3 columns: The first 2 are coordinates of a circle, the 3. are results . How can I convert this x-y-coordinates into a range of degree (range of the x-axis: 0 - 360). I want to show results in a XY-plot. I don't want to create a further column in my data file, I want to convert the values directly with gnuplot. Is this possible?
Just remember your high school geometry and how to convert Cartesian coordinates to polar coordinates. Suppose you have a Cartesian coordinate (x, y). Draw a line between this point and the origin. The angle θ between this line and the x-axis is related by tan θ = y/x and the distance r from the origin is sqrt(x2 + y2).
So your angle θ is just the arc tangent (inverse tangent) of y/x. In gnuplot, this is the atan() function. I'd write something like this:
set angles degrees
plot 'infile.dat' using (atan($2/$1)):3 with points
where column 3 is your "result" (the roughness) and columns 1 and 2 are your Cartesian coordinates. It uses the calculated θ value for the horizontal plotted axis and the roughness for the vertical plotted axis.
The set angles command lets you set the unit used by atan() to degrees or radians. Since you specified a range of 0-360, it is set angles degrees.
It will plot the points in the order as they appear in the file. Notice that depending on the order of points in your data file, the order of the points after this calculation may no longer be visually sequential, so this example uses with points.
I have one design like this:
Now i want to calculate angle between the clicked circle and the position at 90 degrees on outer arc. How do i calculate that ?
I have angle of outer circles in radians.
I have to find the exact centroid of multiple rectangles (Minimum Bounded Rectangle).
Let I have, 3 rectangles and their co-ordinates for the maximum and minimum points
1st rectangle's minimum point (x1,y1) , maximum point (x2,y2)
2nd rectangle's minimum point (x3,y3) , maximum point (x4,y4)
3rd rectangle's minimum point (x5,y5) , maximum point (x6,y6)
I quick solution come over my mind is , I will find possible list of centroids by considering combinations of this 6 points and then take the minimum bounded rectangle of those centroids. It will give me a rectangle R , the centroid of that rectangle is my real centroid.
For example , a combination is (x1,y1)+(x3,y3)+(x5,y5) ,
another combination is (x1,y1)+(x3,y3)+(x6,y6) etc
But i am confused will it give me the real centroid ? Is there any other way to find the centroid ?
I share Spektre's confusion on the problem statement. But if you just want the centroid of the point-set defined by the rectangles, here's how to do it:
If Ai is the area of rectangle i, and Ci is the centroid of rectangle i, then the centroid of all the rectangles taken together is just:
Sum(i = 1..n; Ai Ci)/Sum(i = 1..n; Ai)
The area and centroid of each rectangle is easy to compute from basic geometry.
You can think of each rectangle as having all it's mass (same as the area if we assume unit density). Then we just need the mass-weighted average of those points.
I have 2 squares with the same orientation. I know the coordinate of their centers. They have the same size area.
They may intersect each other. I want to compute their area of their intersection as well as area of their union.
Let's say that their centers are (a, b) for the first square and (x, y) for the second square. The length of one of their sides is l. How can I compute their intersection and their union based on this?
Since they have the same orientation, you can rotate the two squares first so their sides are aligned with the x, y coordinates, then it should be easy to compute what you want.