Click here to Skip to main content
15,895,283 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: calculating the effect of "weighted vectors" Pin
BillWoodruff2-Feb-16 0:31
professionalBillWoodruff2-Feb-16 0:31 
QuestionWhere can I download video for MIT subject “Distributed Algorithms” and “Advanced Algorithms” Pin
nbdxkfq14-Jan-16 13:04
nbdxkfq14-Jan-16 13:04 
AnswerRe: Where can I download video for MIT subject “Distributed Algorithms” and “Advanced Algorithms” Pin
Patrice T15-Jan-16 9:43
mvePatrice T15-Jan-16 9:43 
AnswerRe: Where can I download video for MIT subject “Distributed Algorithms” and “Advanced Algorithms” Pin
Amarnath S16-Jan-16 6:37
professionalAmarnath S16-Jan-16 6:37 
QuestionI want find intersection point between two ellipse or ellipse and circle, can someone please give me useful links or any suggestions. Pin
Member 113286205-Jan-16 18:40
Member 113286205-Jan-16 18:40 
AnswerRe: I want find intersection point between two ellipse or ellipse and circle, can someone please give me useful links or any suggestions. Pin
Beginner Luck5-Jan-16 19:04
professionalBeginner Luck5-Jan-16 19:04 
SuggestionRe: I want find intersection point between two ellipse or ellipse and circle, can someone please give me useful links or any suggestions. Pin
Richard MacCutchan5-Jan-16 21:31
mveRichard MacCutchan5-Jan-16 21:31 
AnswerRe: I want find intersection point between two ellipse or ellipse and circle, can someone please give me useful links or any suggestions. PinPopular
harold aptroot6-Jan-16 0:06
harold aptroot6-Jan-16 0:06 
Circles are trivial. The interesting part is ellipses. I've found this in Graphics Gems V.

Ellipses can be represented by a characteristic 3x3 matrix S, such that the points on the ellipse satisfy x̄Sx̄T = 0, x is a 3-vector representing the coordinate of the point with a homogeneous coordinate for translation. This is probably not too surprising yet, it's reminiscent of a circle with radius zero (lol, but the point is the form) x*x+y*y=0 => x̄x̄T=0 (I'll omit bars on vectors from now on, you can figure it out from context) but with a matrix in between to potentially do some scaling/rotating/translation, and an ellipse is clearly just a transformed circle.

The point(s) of intersection satisfy the equations of both ellipses. So xS1xT = 0 and xS2xT, those points must therefore satisfy axS1xT + bxS2xT = 0. Because linear algebra is, well, linear, you can write that as x(S1 + qS2)xT = 0 where q = b/a. This test is not as strict, it will allow some spurious points, but they can simply be tested against the original equations.

H = S1 + qS2 will again be the characteristic matrix of some conic, not necessarily an ellipse, indeed it could be a bunch of lines. That would be useful, so solve for q (recall that the points we want will work for any q, so we can pick it) such that det(H) = 0. Since H is a 3x3 matrix, this is just a cubic equation which can be solved directly (though slightly annoyingly). The three roots defined three H's.

For each H found that way (most H's will work, but some solutions may not have a useful form), determine which type it is (because of round-off, do the usual floating point "is nearly zero" thing instead of the exact math thing), say the matrix has the form
A B D
B C E
D E F
(it is, because a linear combination of two symmetric matrices is also symmetric, this just names the elements)
  1. A=B=C=0, now vHvT=0 is just Dx+Ey+F=0, the familiar line equation. Because we will be applying linear transformations to the line(s), represent it as two points. Just pick any two points on the line and remember them.
  2. B2-AC=0, some number of parallel lines. Make a rotation matrix for the angle -0.5 atan(2B / (A-C)) and apply it to H. The quadrant doesn't matter so atan2 isn't necessary. The lines will be either horizontal or vertical, if C=0 then they're vertical with the equation Ax²+2Dx+F=0 (beware typos in the book, if you're reading it alongside this), just solve that the regular way giving you up to 2 vertical lines, again represent them by pairs of points. Since we had rotated, apply the reverse rotation to those points. If C!=0, then they were horizontal lines, with the equation Cy²+2Ey+F=0, do the same thing with that.
  3. B²-AC > 0, crossing lines, it's a bit tricky to actually find them. Rotate the same way as above, then translate with (using the rotated H) xoffset=-(CD-BE)/(B²-AC), yoffset=-(AE-BD)/(B²-AC), finally in the rotated and translated H, 0,0 is a trivial point on both lines (their intersection is now in the origin) and we also have 1/sqrt(|A|),1/sqrt(|B|) and 1/sqrt(|A|),-1/sqrt(|B|). Translate them back, then rotate them back.
  4. Some other form, pick a different H.
Now you have a bunch of lines. Transform them and the first ellipse such that the ellipse becomes a circle, test all the transformed lines against the circle, then inverse-transform the intersections you found. Testing points against the second ellipse is easy, but keep in mind you will have plenty of rounding error by now.

There's C code implementing this here: http://www.realtimerendering.com/resources/GraphicsGems/gemsv/ch2-6/conmat.c[^] and you should probably read the relevant chapter from the book as well.

modified 6-Jan-16 6:12am.

GeneralRe: I want find intersection point between two ellipse or ellipse and circle, can someone please give me useful links or any suggestions. Pin
Member 113286206-Jan-16 1:33
Member 113286206-Jan-16 1:33 
GeneralRe: I want find intersection point between two ellipse or ellipse and circle, can someone please give me useful links or any suggestions. Pin
harold aptroot8-Jan-16 3:38
harold aptroot8-Jan-16 3:38 
QuestionProbability Pin
Member 122449725-Jan-16 0:18
Member 122449725-Jan-16 0:18 
AnswerRe: Probability Pin
Daniel Pfeffer5-Jan-16 0:30
professionalDaniel Pfeffer5-Jan-16 0:30 
AnswerRe: Probability Pin
Afzaal Ahmad Zeeshan5-Jan-16 0:39
professionalAfzaal Ahmad Zeeshan5-Jan-16 0:39 
QuestionConverting From Decimal to Custom Counting Definition Pin
BlueIshDan24-Dec-15 3:45
BlueIshDan24-Dec-15 3:45 
AnswerRe: Converting From Decimal to Custom Counting Definition Pin
Patrice T24-Dec-15 5:44
mvePatrice T24-Dec-15 5:44 
GeneralRe: Converting From Decimal to Custom Counting Definition Pin
Patrice T24-Dec-15 5:57
mvePatrice T24-Dec-15 5:57 
GeneralRe: Converting From Decimal to Custom Counting Definition Pin
BlueIshDan24-Dec-15 5:59
BlueIshDan24-Dec-15 5:59 
GeneralRe: Converting From Decimal to Custom Counting Definition Pin
BlueIshDan24-Dec-15 6:02
BlueIshDan24-Dec-15 6:02 
GeneralRe: Converting From Decimal to Custom Counting Definition Pin
Patrice T24-Dec-15 6:09
mvePatrice T24-Dec-15 6:09 
GeneralRe: Converting From Decimal to Custom Counting Definition Pin
Patrice T24-Dec-15 13:51
mvePatrice T24-Dec-15 13:51 
GeneralRe: Converting From Decimal to Custom Counting Definition Pin
BlueIshDan29-Dec-15 0:21
BlueIshDan29-Dec-15 0:21 
GeneralRe: Converting From Decimal to Custom Counting Definition Pin
Patrice T29-Dec-15 2:45
mvePatrice T29-Dec-15 2:45 
Questionwhat kind of algorithms we use to find minimum spanning tree Pin
Member 1211381321-Dec-15 5:39
Member 1211381321-Dec-15 5:39 
AnswerRe: what kind of algorithms we use to find minimum spanning tree Pin
Chris Losinger21-Dec-15 6:31
professionalChris Losinger21-Dec-15 6:31 
GeneralRe: what kind of algorithms we use to find minimum spanning tree Pin
harold aptroot21-Dec-15 6:57
harold aptroot21-Dec-15 6:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.