intersection

Intersection of lists

空扰寡人 提交于 2020-01-30 05:17:24
问题 Is there a better, more elegant and concise, way to get the intersection of two lists in C#? In C# a method to calculate an intersection of list of dates is: public List<DateTime> dates_common(Timeserie ts1, Timeserie ts2) { var dt1 = new HashSet<DateTime>(ts1.dates); var dt2 = new HashSet<DateTime>(ts2.dates); dt1.IntersectWith(dt2); var dt = new DateTime[dt1.Count]; dt1.CopyTo(dt); return new List<DateTime>(dt); } In Ruby one would do this as: def dates_common(ts1, ts2) dt1 = ts1.dates.to

R - locate intersection of two curves

假如想象 提交于 2020-01-30 03:16:36
问题 There are a number of questions in this forum on locating intersections between a fitted model and some raw data. However, in my case, I am in an early stage project where I am still evaluating data. To begin with, I have created a data frame that contains a ratio value whose ideal value should be 1.0. I have plotted the data frame and also used abline() function to plot a horizontal line at y=1.0 . This horizontal line and the plot of ratios intersect at some point. plot(a$TIME.STAMP, a

Intersection between two lines as defined by points without extending lines

不问归期 提交于 2020-01-25 06:30:06
问题 I know there are various posts on stackoverflow about given two lines defined by two points each, being able to calculate the intersection, but typically those solutions extend the lines as opposed to treating their physical sizes. Background search: The typical function used to calculate the intersection of two lines as defined by points is shown below, but credit goes to here. // Finds the intersection of two lines, or returns false. // The lines are defined by (o1, p1) and (o2, p2). bool

Find the arc of the intersection between circle and rectangle

末鹿安然 提交于 2020-01-24 21:08:44
问题 I need to find the largest arc created from the intersection of a circle and a rectangle. I have the center of the circle, the radius and the coordinates of the rectangle, and I need to find the angle of the intersection points with the center of the circle. I have a code that works, but it computes the solution iterating the points of the circumference, and I was wondering if there's a more elegant way to calculate the solution using trigonometry instead of "brute force". That's my code:

Find the arc of the intersection between circle and rectangle

只愿长相守 提交于 2020-01-24 21:06:28
问题 I need to find the largest arc created from the intersection of a circle and a rectangle. I have the center of the circle, the radius and the coordinates of the rectangle, and I need to find the angle of the intersection points with the center of the circle. I have a code that works, but it computes the solution iterating the points of the circumference, and I was wondering if there's a more elegant way to calculate the solution using trigonometry instead of "brute force". That's my code:

Find the arc of the intersection between circle and rectangle

…衆ロ難τιáo~ 提交于 2020-01-24 21:06:05
问题 I need to find the largest arc created from the intersection of a circle and a rectangle. I have the center of the circle, the radius and the coordinates of the rectangle, and I need to find the angle of the intersection points with the center of the circle. I have a code that works, but it computes the solution iterating the points of the circumference, and I was wondering if there's a more elegant way to calculate the solution using trigonometry instead of "brute force". That's my code:

Remove holes in polygon

浪子不回头ぞ 提交于 2020-01-24 13:44:20
问题 I am trying to solve the following problem in R : I have a polygon object defined by a list l with two components x and y. The order defines the edges of the polygon. For instance : l=list( x=c(-1.93400738955091,0.511747161547164,1.85047596846401,-1.4963460488281,-1.31613255558929,-0.0803828876660542,1.721752044722,-0.724002506376074,-2.08847609804132,2.13366860069641), y=c(-1.02967154136169,1.53216851658359,-1.39564869249673,-1.21266011692921,1.6419616619241,-1.87141898897228,0

How to Intersect two Arrays?

廉价感情. 提交于 2020-01-24 13:34:45
问题 I'm working with VB.Net, and have two one-dimensional Arrays. Is there an Inbuilt function for finding the elements that are common to both of them? Or do I have to write one for myself? 回答1: I'm afraid you'll have to write one for yourself, because there is no built-in function in .NET 2.0. Look at this StackOverflow question for ideas about how you could implement it yourself. 回答2: If you can use the LINQ extension methods (VB9), then yes - you can use Enumerable.Intersect(): dim a as

How to Intersect two Arrays?

纵然是瞬间 提交于 2020-01-24 13:30:11
问题 I'm working with VB.Net, and have two one-dimensional Arrays. Is there an Inbuilt function for finding the elements that are common to both of them? Or do I have to write one for myself? 回答1: I'm afraid you'll have to write one for yourself, because there is no built-in function in .NET 2.0. Look at this StackOverflow question for ideas about how you could implement it yourself. 回答2: If you can use the LINQ extension methods (VB9), then yes - you can use Enumerable.Intersect(): dim a as

intersection between a line and square

让人想犯罪 __ 提交于 2020-01-16 14:52:42
问题 I have a square in 2d space (width = height). The square is currently defined by two points: BottomLeft(X1,Y1) and TopRight(X2,Y2). The square is axis-aligned, so finding the other two corners is as easy as (X1, Y2) and (X2, Y1). I also have two points - one is always inside the square, and the other is definitely outside. They aren't necessarily at the centre of the square - they can be wherever. I know their coordinates too. What I need is to find the intersection point between the line