none
intersection is seen but could not be marked RRS feed

  • Question

  • Is there any way to detect the intersection of two graphics objects drawn (could be two line or two curves or two splines or a line and a curve etc., any combination) drawn creating a graphics object which derives itself from a bitmap image and then the graphics is transferred to the picturebox1 as bitmap itself

    more like:-

    private bit as new bitmap

    dim g as graphics=graphics.fromimage(bit)

    g.draw<shape>(pens,pts)

    picturebox1.image=bit

    Right now, I could draw these shapes, and could even see the intersecting points on the screen but can't mark them. Is there any way to mark all the intersecting points made by different shapes?

    Is there a way to check for different point on the screen if its been marked with pen and if it has been marked once or twice? This may also give intersection points.

    Thanks,

    ps: explanation in visual basic compatible to visual studio is appreciated but other language is OK too 


    • Edited by Ruchi12 Wednesday, December 27, 2017 6:36 PM
    Wednesday, December 27, 2017 6:28 PM

All replies

  • Hi Ruchi12,

    Thank you for posting here.

    As I know, if you want to get the quadrilateral diagonal intersection, you could use the points with formula which you used to draw the lines.

    A(x1,y1) B(x2,y2) C(x3,y3) D(x4,y4)
    DiagonalAC:y-y1=(y3-y1)/(x3-x1)*(x-x1)
    DiagonalBD:y-y2=(y4-y2)/(x4-x2)*(x-x2)
    (y3-y1)/(x3-x1)*(x-x1)+y1=(y4-y2)/(x4-x2)*(x-x2)+y2
    (y3-y1)(x4-x2)(x-x1)+y1(x3-x1)(x4-x2)=(y4-y2)(x3-x1)(x-x2)+y2(x3-x1)(x4-x2)
    (y3-y1)(x4-x2)(x-x1)-(y4-y2)(x3-x1)(x-x2)=(x3-x1)(x4-x2)(y2-y1)
    x[(y3-y1)(x4-x2)-(y4-y2)(x3-x1)]=(x3-x1)(x4-x2)(y2-y1)+x1(y3-y1)(x4-x2)-x2(y4-y2)(x3-x1)
    x=[(x3-x1)(x4-x2)(y2-y1)+x1(y3-y1)(x4-x2)-x2(y4-y2)(x3-x1)]/[(y3-y1)(x4-x2)-(y4-y2)(x3-x1)]
    y=(y3-y1)/(x3-x1)*(x-x1)+y1
    =(y3-y1)[(x4-x2)(y2-y1)+(x1-x2)(y4-y2)]/[(y3-y1)(x4-x2)-(y4-y2)(x3-x1)]+y1
    Hence point is
    ([(x3-x1)(x4-x2)(y2-y1)+x1(y3-y1)(x4-x2)-x2(y4-y2)(x3-x1)]/[(y3-y1)(x4-x2)-(y4-y2)(x3-x1)],(y3-y1)[(x4-x2)(y2-y1)+(x1-x2)(y4-y2)]/[(y3-y1)(x4-x2)-(y4-y2)(x3-x1)]+y1)

    You could use the formula to get the points in your code.

    But, for curves, I am nor sure what curves you used to get the point. Please provide more information about that.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 2, 2018 1:46 AM
    Moderator