Orientation of lines?

In summary, the conversation discusses the challenge of finding the overall statistics of line orientation within a larger square by looking at the line statistics within a smaller square. The speaker has attempted different methods, including using a "weight" component and probability theory, but has found that the issue lies in extremely narrow sample spaces. They have come to the conclusion that using randomly generated lines in a space with the same dimensions as the sample space and measuring their orientation may be the best approach. The final step would be to use the computed value as the "weight" in calculating the overall line orientation in the larger square.
  • #1
tresty
6
0
Hi everyone,

I have a question that seems simple, but I cannot come up with the right answer.

Suppose you have a square with sides 2 (xrange[-1:1], yrange[-1:1])

Further suppose that there are equal number of vertical, horizontal and diagonal (exactly 45 degrees) lines of various lengths inside the square.

Now draw a square inside with sides 1 (xrange[-0.5:0.5],yrange[-0.5:0.5]).
The goal is to find the overall statistics of line orientation in the bigger square from looking at the line statistics inside smaller square.

I wrote a simple program to count the number of lines inside the square for each type of orientation, and found that there are always slightly more diagonal lines(vertical and horizontal are about the same).

When I change the sample space, let's say to something like a rectangle of width 2 and height 1 (xrange[-1:1] yrange[-0.5:0.5]) I get more vertical counts than horizontal counts with diagonal count in between.

From these results I calculate the average orientation of lines for different sample spaces and get different answers (so it doesn't give me the right average orientation of the lines in the larger square).

What I am currently thinking is adding a component of "weight" in certain directions when calculating the average, so that no matter what shape the sample space is, the weighted average will approximately be the same.

Now my question is, how would you determine this "weight"?
I've tried simple things like the distance from the center to the edge of the sample space but it didn't work.

Anyone have any ideas or experience with this kind of thing?

Thank you so much!
 
Mathematics news on Phys.org
  • #2
I think the most precise way is to find an equation for the line count distribution.
Each line has three parameters (horizontal lines: x1,x2,y; vertical lines x,y1,y2; diagonal lines: x1,y,x2)
Now you can assume some distribution for these independent coordinates. Maybe a uniform makes most sense. Then you can predict the average number of lines found in a square (for example a horizontal line is in the square if a<x1<b or a<x2<b or x1<a<b<x2 AND c<y<d...; use probability theory with things as integrals)
From this you can find the equation to convert from average counts in one square to average counts in another square.

Horizontal and vertical lines are very easy.
But note that for diagonal lines you have some funny line crossing a corner only.
 
  • #3
Thanks for your reply Gerenuk,

Yes, when the sides are flat I think there's an easy way to calculate the probability.
Now, I really don't know about the intermediate angles (1 to 89 degrees).
Something to do with spatial sampling bias I suppose...hmm..
 
  • #4
There may be some way of calculating the weight you should use, but it will change based on the distribution of the length of the lines. I think a key question is: if you find a line in your smaller square with one or more endpoints that lie outside the smaller square (so you only see a segment of the overall line), do you have access to the full length of that line? If so, I think you can come up with a pretty good guess for the number of lines and lengths in the larger square from the smaller square. If not, maybe not.

For the very, very small lines, you can assume that the lines you see inside the smaller square are representative of the lines contained in the larger square (assuming your lines are uniformly randomly distributed in the larger square).

As your lines get larger, you will see a greater percentages of the diagonal lines than the horizontal or vertical. When your line lengths are sqrt(2) or larger, it becomes impossible to place a diagonal line within the larger square that is not also visible in the smaller square, so you know you can see 100% of all the diagonal lines longer than sqrt(2). In contrast you can see only 50% of all the horizontal and vertical lines of that length that exist in the larger square by looking in the smaller square. (50% of horizontal and vertical lines with length .5 or greater are visible in the smaller square).

I think for horizontal lines and vertical lines, you're right, it's pretty easy... I think.
You miss 50% of all the horizontal lines straight off, if Y>.5 or <-.5.

Of all the horizontal lines for which -.5<y<.5,
When the horizontal lines are > length of .5 you can see all of them in the smaller square.​
When the horizontal lines are 0< length L < .5 you can see... 1-(1-2L)/(2-L) of them​

Or, looking at all horizontal lines, -1 < y < 1, you see:
25% of all lines of ~0 length
50% of all lines of .5 or greater length
and .5*(L+1)/(2-L) of all the other lines where L = length of line.

...Should be able to work backwards from there.

Diagonals and other angles should be possible in the same way, but with slightly more complicated math...
 
  • #5
Thanks for your reply kjl.

I've now tried a whole bunch of things, and have come to a final result.
After taking different approaches to this problem, including the weight method and the probability method, I noticed that the real problem comes into play when the sample space is extremely narrow. In such sample spaces, the number of lines going through the widest part is greatest (i.e if the sample space is a narrow vertical strip then there will be more horizontal lines going through the sample space than vertical ones)

I am actually pretty sure using probability is the way to take an estimate of the overall distribution of line orientation. But even if it possible to find such average value, I'm not too sure if the uncertainty is acceptable (it's probably going to be huge).

So the approach I took was:
1.generate random lines in a space with the same dimensions as the sample space
2.measure the orientation of each lines
3. discretized the angle, and count how many lines have the same orientation
4.compute (#lines with orientation X in data)/(#lines with orientation X in random data)
5.use the computed value as the "weight" to calculate the average.

The results are looking good (so far) , and I am hoping I find no problem with this approach.

Thanks to Gerenuk and kjl for providing me ideas, and everyone else who took a look at this thread!
 
  • #6
I think for the diagonal lines, it might be easier conceptually (to avoid errors) to tilt the squares 45 degrees. Then apply an argument like kjil's to your newly made vertical lines, noting that the probability of landing inside the smaller square depends on where the line is located horizontally. You'll have to integrate a probability distribution but I imagine it will be a simple function
 

1. What is the orientation of lines?

The orientation of lines refers to the direction in which a line is positioned. This can be horizontal, vertical, or diagonal.

2. How do you determine the orientation of a line?

The orientation of a line can be determined by observing the angle at which the line is positioned. A horizontal line has a 0 degree angle, a vertical line has a 90 degree angle, and a diagonal line can have any angle between 0-90 degrees.

3. Why is the orientation of lines important in science?

The orientation of lines is important in science because it can provide information about the structure and properties of objects. For example, the orientation of lines in a crystal lattice can determine its strength and stability.

4. How can the orientation of lines be changed?

The orientation of lines can be changed through physical manipulation or through external forces such as gravity or magnetic fields. In some cases, the orientation of lines can also be altered through chemical processes.

5. Can the orientation of lines affect data analysis in scientific experiments?

Yes, the orientation of lines can greatly impact data analysis in scientific experiments. For instance, the orientation of lines in an image can affect image recognition and measurements, leading to potential errors in data analysis. Therefore, it is important to consider the orientation of lines when conducting experiments and analyzing data.

Similar threads

Replies
9
Views
830
  • General Math
Replies
5
Views
2K
Replies
2
Views
1K
  • General Math
Replies
2
Views
1K
  • General Math
Replies
8
Views
2K
  • General Math
Replies
13
Views
2K
  • General Math
Replies
20
Views
1K
Replies
1
Views
752
Back
Top