Converte circle coordinates in to degree values in gnuplot - gnuplot

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.

Related

Select data within the area of a series in Excel

Ok, so I have two data series graphed, like so.
These are two scatter plots, based on x and y values, that are produced using a combo chart. The orange scatter plot is an ellipse whose calculation is based upon aspects relating to the purple scatter plot. I have made the orange ellipse in order to... well... select the part of the purple scatter plot that I want to do other things with. Problem is, I don't know how to actually select the data points this area refers to.
The data for this chart is based upon four columns: A,B (forming the purple plot) and C,D (forming the orange plot). Reordering the columns makes little difference.
Implementing Anger's proposed solution below, all instances seem to return true. Also, there happen to be more scatter plot rows than there are ellipse rows, so I'm not sure how to solve that for the sake of comparison.
If you specify the equation of the ellipse (center point and semi-major/minor axes), you can use the equation of the ellipse to flag points that are inside or outside.
if( ((Ex-x)/Lx)^2+((Ey-y)/Ly)^2 < 1, "INSIDE", "OUTSIDE")
Where Ex, Ey are the coordinates of the ellipse's center; x, y are your data point's coordinates, and Lx, Ly are the semi-major and semi-minor axes.
Just by eye, I would say Ex = 1.8, Ey = 1.21, Lx = 0.6, and Ly = 0.5.

Simplest way to convert polar coordinates to Cartesian points

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)

Converting plot X, Y to location to draw arrow/line

I have a bunch of data that I'm plotting as point plots. The data is simply a column for X and a column for Y. The catch here though is this is plotted using axes x2y2.
The x1y1 is used for a histogram. The X axis is the same range for both plots.
I know how to derive the X coordinate, but am wondering if there is an easy way to determine the Y value to use to draw an arrow. I want to draw an arrow callout for an arbitrary point on the point plot.
y1 and y2 are independent.
The coordinates for drawing the arrow can refer to different coordinate systems (first, second, character, screen, and graph, see help coordinates).
So, to draw an arrow e.g. from the top-middle of the plot (graph 0.5, graph 1) to x2 = 1, y2 = 2 (second 1, second 2) you would write
set arrow from graph 0.5, graph 1 to second 1, second 2 head

Forming right triangle with given hypotenuse and angles

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.

Geometry - Intersection over Union for 2 squares with the same orientation

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.

Resources