Line intersection in lawbview 7.1

hi
i m using labview 7.1 for sme image processing
i have detected 4 circles in an image which are in the following fashion
                                       1
                                    2     3
                                       4
From the IMAQ find circles option, i get the following data:
pos x     pos x     pos x     pos x    - this is the x pos of the center
pos y     pos y     pos y     pos y   -  this is the y pos of the center
radius    radius    radius   radius   -  radius in pixel
core       core      core      core     -  area in pixel
now i have to find the intersection of the lines passing through the centers of the (1st,4th) & (2nd,3rd) circle centres.
the line intersection option is asking for the co ordinates of the points of the 1st & 2nd line . How can i give the point co ordinates from the circle data?
i.e for the 1st line i must enter the x & y coordinates of the center of 1st & 4th circle and for the 2nd line, x & y of the centers of the 2nd & 3rd cirlces
how can i do it?

james bond,
    I'm glad to hear that the snapshot helped.  As far as calibration, I believe that you are wanting to set up a calibration in LabVIEW, right?  It sounds like you know how to set up calibrations in Vision Assistant.  One of the more common ways to calibrate an image using a sheet of paper with a grid of dots on it with a known distance between the dots.  This is talked about in more detail in this document which also has some helpful links at the bottom:
http://digital.ni.com/public.nsf/websearch/5FC615E2B4CFE8FA86256AC4007C9A42?OpenDocument
    There are several sample programs for image calibration in LabVIEW, specifically in the Simple Calibration Example.vi.  If you open that one you can see that they use a VI called IMAQ Set Simple Calibration.vi.  This VI will handle calibrations when you input your image and the various calibration settings as in the example VI.  What I would recommend, though, is to do your calibration in Vision Assistant like you were mentioning, then you can create LabVIEW code (Tools >> Create LabVIEW VI...) from it and it will create all of the VI's and settings you need to calibrate your image and use your calibrated image in LabVIEW.  If I am misunderstanding please let me know.  Thank you!
-Allison S.
Applications Engineering
-Allison S.
Calibration Services
Product Support Engineer

Similar Messages

  • How to make a line intersect with a path at random angles?

    How do you make a line intersect with the anchor point of a half circle when you want the line to continue on past the anchor point of the half circle at a random angle?

    Howdy.
    Try this:
    Lock the semicircle. With the pen tool, draw a line from the point of origin to the anchor point of the semicircle. It will still snap even though it's locked.
    Now, we use Jet's scale idea. Select the Scale Tool (S). Click on the point of origin to position the reference point. It will snap. Now, while holding down the Shift Key, drag right and down. The line segment will stay snapped to the endpoint while you drag (highlighted). You can drag it as far as you want.
    That's it.
    Peace,
    Lee
    PS: It's pretty much all Jet's method with the benefit of the OP's screenshot of what he was trying to accomplish. Jet offered the best answer, it looks like to me.

  • Line intersection cleaning

    I have a 1 point rectangle and a 2 pt diagonal line intersection -
    when zoomed in the diagonal line corners are outside the rectangle.
    is there a way to clean this without making rectangle into lines?
    thanks in advance

    I made my own arrowhead for mitered corners.
    Download this broken image and change the suffix to .ai rather than .jpg (Control-click or right-click and choose save as...)
    (Mac) Control-click on the Adobe Illustrator App and Choose "Show Package Contents" to get into the app itself. Then you can replace (after backing up the original) the Arrowheads.ai file located in Adobe Illustrator CS5.app/Resources/en_US/
    Then relaunch AI and the mitered arrow wil be at the bottom of the list.

  • Line intersection

    Hi
    Is there a method in Java that can calculate the intersection of two lines. I know that there is a Line2D.lineIntersects but this method only returns true or false if the two lines intersect. I need the X, Y point where the 2 lines intersect.

    That point should be very easy to calculate,
    unless
    the lines are parallell or close to.Why would lines being close to parallel make the
    point of intersection more difficult to calculate?
    A valid point, it makes zero difference (ignoring rounding errors that
    may classify non-parallel lines as parallel).Rounding errors (if, for example ints were involved) leading to
    non-parallel being treated as parallel (or vice versa) would be a
    problem.
    With or without rounding error, the equations can yield "signed infinities"
    that have to be dealt with.
    Also there could be a question of precision: if the original line
    segments were the result of measurement then how close they
    are to parallel could make the difference between whether the
    intersection is a reliably calculated value, or a more of a guess.
    The OP shouldn't be put off! It's a reasonable question, and MLRon's
    link provides a simple solution. But it also seems quite reasonable
    to warn that - depending on the context of the original problem -
    being parallel or close to parallel could involve problems.

  • Lines intersecting that has a point in a polygon

    Hi Spatial Community,
    I would like to get your expertise in trying to see how can we get this done via Oracle Spatial.
    The requirement is to write a file
    - passed intersection of line that have a point within a polygon
    - failed intersections( doe snot have any line intersecting) that have a point within a polygon
    Any clues is much appreciated.
    Edited by: CrackerJack on Feb 25, 2013 12:46 PM

    Comments before have been pretty much on the money perhaps I might just add
    Using the cola_markets example from the manual...
    -- Return the topological intersection of two geometries.
    SELECT SDO_GEOM.SDO_INTERSECTION(c_a.shape, c_c.shape, 0.005)
    FROM cola_markets c_a, cola_markets c_c
    WHERE c_a.name = 'cola_a' AND c_c.name = 'cola_c';
    SDO_GEOM.SDO_INTERSECTION(C_A.SHAPE,C_C.SHAPE,0.005)(SDO_GTYPE, SDO_SRID, SDO_PO
    SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
    AY(4, 5, 3, 3, 5, 3, 5, 5, 4, 5))
    So that finds the ones that DO interact
    To do the DISJOINT: The boundaries and interiors do not intersect.
    Use SDO_ANYINTERACT as someone else also suggested
    The expression SDO_ANYINTERACT(geometry1,geometry2) = 'TRUE' evaluates to TRUE for object pairs that have the ANYINTERACT topological relationship, and FALSE otherwise.
    The False version which your will need
    SQL> SELECT c.mkt_id, c.name
    FROM cola_markets c
    WHERE SDO_ANYINTERACT(c.shape,
    SDO_GEOMETRY(2003, NULL, NULL,
    SDO_ELEM_INFO_ARRAY(1,1003,3),
    SDO_ORDINATE_ARRAY(4,6, 8,8))
    ) != 'TRUE';
    2 3 4 5 6 7
    MKT_ID NAME
    3 cola_c
    5 cola_d5
    And for completeness the reverse
    SQL> SELECT c.mkt_id, c.name
    FROM cola_markets c
    WHERE SDO_ANYINTERACT(c.shape,
    SDO_GEOMETRY(2003, NULL, NULL,
    SDO_ELEM_INFO_ARRAY(1,1003,3),
    SDO_ORDINATE_ARRAY(4,6, 8,8))
    ) = 'TRUE';
    2 3 4 5 6 7
    MKT_ID NAME
    1 cola_a
    2 cola_b
    4 cola_d
    Cheers
    Rich

  • Need help in a game design.Cirles,lines intersections

    Hello,
    Im trying to create a board game (the go game) but i have problems with the design. Till now i have design a 19 * 19 table and what i want is when i click with the mouse on this table to display circles, but i want them exactly on the intersection. With my program i get circles everywhere i click and not on the intersection of the line.
    So if anyone can help me,i would like to tell me, how can i place the circle exactly on the intersection? Also i would like to eliminate the clicks just on the table and not outside of it.
    Please help if anyone knows, im not that expert in java
    My code is this till now.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class goGame extends JFrame {
    private int x1Value , y1Value ;
    boolean isWhitesTurn = true,first = true;
    public goGame()
    super( "Go game" );
    Color redbrown = new Color (75,17,17);
    setBackground(redbrown);
    addMouseListener(
    // anonymous inner class
    new MouseAdapter() {
    // store drag coordinates and repaint
    public void mouseClicked( MouseEvent event )
    x1Value = event.getX();
    y1Value = event.getY();
    repaint();
    } // end anonymous inner class
    ); // end call to addMouseMotionListener
    setSize( 700,550 );
    setVisible(true);
    public void paint( Graphics g )
    Graphics2D graphics2D = (Graphics2D ) g;
    Color redbrown = new Color (75,17,17);
    g.setColor(redbrown);
    Color lightbrown = new Color (192,148,119);
    g.setColor(lightbrown);
    if (first) {
    //paint yellow the big rectangle
    graphics2D.setPaint(new GradientPaint (600,100, Color.yellow,100, 10,Color.red,true));
    graphics2D.fillRect(60,60,450,450);
    graphics2D.setPaint(Color.black);
    graphics2D.setStroke(new BasicStroke(3.0f));
    //draw rows
    int y=60;
    for (int n=0; n<=18 ; n++)
    g.drawLine(60,y,510,y );
    y= y + 25;
    //draw columns
    int x = 60;
    for (int n=0; n<=18 ; n++)
    g.drawLine(x,510,x,60);
    x = x + 25;
    g.setColor(Color.green) ;
    //draw the 1st 3 vertical dots
    int z = 133;
    for (int n=0; n<=2; n++)
    g.fillOval(133,z,5,5);
    z = z + 150;
    //draw the 2 vertical dots of the 1st row-dot , the 1 already exists
    int w = 283;
    for (int n =0; n<=1; n++)
    g.fillOval(w,133,5,5);
    w = w + 150;
    //draw the 2 vertical dots of the 2nd row-dot
    int t = 283;
    for (int n=0; n<=2; n++)
    g.fillOval(283,t,5,5);
    t = t + 150;
    //draw the last dots
    g.fillOval(433,283,5,5);
    g.fillOval(433,433,5,5);
    first = false;
    if (isWhitesTurn) g.setColor(Color.white);
    else g.setColor(Color.black);
    g.fillOval( x1Value, y1Value,20,20 );
    isWhitesTurn = !isWhitesTurn ;
    // execute application
    public static void main( String args[] )
    goGame application = new goGame();
    application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    This will capture vertical and horizontal
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class GoGame extends JFrame
    public GoGame()
         getContentPane().setLayout(null);
         setBounds(10,10,510,520);
         getContentPane().add(new TheTable());
         setVisible(true);
    public class TheTable extends JPanel
         int[][]points  = new int[19][19];
         boolean black  = true;
    public TheTable()
         setBounds(20,20,453,453);
         addMouseListener(new MouseAdapter()
              public void mouseReleased(MouseEvent m)
                   Point p = clickOnIntersection(m.getPoint());
                   if (p != null && points[p.x/25][p.y/25] == 0)
                        int x = p.x/25;
                        int y = p.y/25;
                        if (black)
                             points[x][y] = 1;
                             black = false;
                        else
                             points[x][y] = 2;
                             black = true;
                        capture(x,y);
                        repaint();
    private Point clickOnIntersection(Point p)
         Rectangle rh = new Rectangle(0,0,getWidth(),4);
         Rectangle rv = new Rectangle(0,0,4,getHeight());
         for (int h=0; h < 19; h++)
              rh.setLocation(0,h*25-1);
              if (rh.contains(p))
                   for (int v=0; v < 19; v++)
                        rv.setLocation(v*25-1,0);
                        if (rv.contains(p)) return(new Point(v*25+1,h*25+1));
         return(null);
    private void capture(int x, int y)
         onTheY(x,y,points[x][y]);
         onTheX(x,y,points[x][y]);
    private void onTheY(int x, int y, int col)
         for (int j=x-1; j > -1; j--)
              if (points[j][y] == 0) break;
              if (points[j][y] == col)
                   outOnY(j,x,y);
                   break;
         for (int j=x+1; j < 19; j++)
              if (points[j][y] == 0) break;
              if (points[j][y] == col)
                   outOnY(x,j,y);
                   break;
    private void onTheX(int x, int y, int col)
         for (int j=y-1; j > -1; j--)
              if (points[x][j] == 0) break;
              if (points[x][j] == col)
                   outOnX(j,y,x);
                   break;
         for (int j=y+1; j < 19; j++)
              if (points[x][j] == 0) break;
              if (points[x][j] == col)
                   outOnX(y,j,x);
                    break;
    private void outOnY(int f, int t, int y)
         for (f=f+1; f < t; f++) points[f][y] = 0;
    private void outOnX(int f, int t, int x)
         for (f=f+1; f < t; f++) points[x][f] = 0;
    public void paintComponent(Graphics g)
         super.paintComponent(g);
         Graphics2D g2 = (Graphics2D)g;
         g2.setPaint(new GradientPaint(getWidth(),getHeight(),Color.yellow,0,0,Color.red,true));
         g2.fillRect(0,0,getWidth(),getHeight());
         g2.setColor(Color.black);
         for (int n=0; n < 19; n++)
              g2.fillRect(0,n*25,getWidth(),3);
              g2.fillRect(n*25,0,3,getHeight());
         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);          
         g2.setColor(Color.green) ;
         for (int n=0; n < 3; n++)
              g2.fillOval(25*3-1,n*150+74,5,5);
              g2.fillOval(25*9-1,n*150+74,5,5);
              g2.fillOval(25*15-1,n*150+74,5,5);
         for (int x=0; x < 19; x++)
              for (int y=0; y < 19; y++)
                   if (points[x][y] != 0)
                        if (points[x][y] == 1) g.setColor(Color.black);     
                        if (points[x][y] == 2) g.setColor(Color.white);     
                        g2.fillOval(x*25-9,y*25-9,20,20);
    public static void main(String[] args)
         GoGame game = new GoGame();
         game.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }Noah

  • Line Intersection retuns point instead line segment

    Hi all,
    I want to intersect two lines with the function sdo_intersection (Oracle8i).
    However, as result I get always a point instead of a line segment.
    Any suggestions ??
    Thanks Peter
    Following the Script:
    /* Table Theme2 */
    CREATE TABLE THEME2(ID     NUMBER, GEOM MDSYS.SDO_GEOMETRY);
    /* Update Metadata */
    INSERT INTO USER_SDO_GEOM_METADATA (TABLE_NAME, COLUMN_NAME, DIMINFO)
    VALUES ('THEME2', 'GEOM', MDSYS.SDO_DIM_ARRAY
    (MDSYS.SDO_DIM_ELEMENT('X', 2546727.982208079, 2629500.677188804, 0.000000050),
    MDSYS.SDO_DIM_ELEMENT('Y', 5479508.594623252, 5585930.631027042, 0.000000050) ) );
    COMMIT;
    /* Insert 2 Lines */
    insert into theme2 values (1,SDO_GEOMETRY(2002, 82015, NULL,
    SDO_ELEM_INFO_ARRAY(1, 2, 1),SDO_ORDINATE_ARRAY(
    2546727.98, 5570612.31, 2551027.86, 5558787.64, 2554252.77,
    5549112.91, 2570914.81, 5536213.27, 2580589.54, 5532988.36,
    2612569.9, 5524657.34, 2621438.4, 5512563.92, 2622782.11, 5491870.75, 2629500.68, 5479508.59))
    insert into theme2 values (2,mdsys.SDO_GEOMETRY(2002, 82015, NULL,
    mdsys.SDO_ELEM_INFO_ARRAY(1, 2, 1), mdsys.SDO_ORDINATE_ARRAY(
    2619288.46, 5585930.63, 2613913.61, 5568731.11, 2608538.76, 5550456.62,
    2599132.77, 5535675.78, 2597789.06, 5527344.76, 2577095.89, 5517938.77, 2556671.46,
    5513638.89, 2547534.21, 5509339.01))
    /* Intersect */
    select sdo_geom.sdo_intersection(b.geom,a.geom,0.05)
    from theme2 a, theme2 b
    where a.id=1 and b.id=2;
    /* result */
    TEST(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
    SDO_GEOMETRY(2001, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(2597969.08, 5528460.91))

    The two lines you've provided intersect at a single point, which is by definition not a line.
    If you want to return a line, then the intersection has to happen along some length of the line.
    Also, whenever I look at geometries posted I always run sdo_geom.validate_geometry on the
    data.
    Your user_sdo_geom_metadata should include the srid value stored in the geometries.
    The bounds of your user_sdo_geom_metadata should be a bit larger to encompass
    both geometries.
    Regards,
    Dan

  • Line to line intersection point

    If i have a line with end points ( x1 , y1 ) ( x2 , y2 ) and
    another line that crosses it, and its end points are ( x3 , y3 ) ( x4 , y4 )
    how do i get the intersection point ( IPx , IPy ) ?

    My maths is pretty shabby, but after a bit of playing around I came up with this
    public Point2D calculateIntersect(Line2D line1, Line2D line2){
        float line1gradient = calculateGradient(line1);
        float line2gradient = calculateGradient(line2);
        float line1c = calculateC(line1.getP1(), line1gradient);
        float line2c = calculateC(line2.getP1(), line2gradient);
        float x = (line2c - line1c) / (line1gradient - line2gradient);
        float y = line1gradient * x + line1c;
        return new Point2D.Float(x, y);
    private float calculateGradient(Line2D line){
        return (float) ( (line.getP2().getY() - line.getP1().getY()) / (line.getP2().getX() - line.getP1().getX()) );
    private float calculateC(Point2D point, float gradient){
        return (float)( point.getY() - ( point.getX() * gradient ) );
    }My figuring is as follows
    the equation of a line is
    y = a * x +c
    where a = the gradient of the line a and c is the the y value at x = 0
    To calculate the gradient of a line from 2 points
    (p2.y - p1.y) / (p2.x - p1.x)
    and to calculate the value of c for the line
    p.y - p.x * gradient
    so if you have 2 lines with common x and y you have
    y = a1 * x + c1
    and
    y = a2 * x + c2
    so by substitution
    a1 * x + c1 = a2 * x + c2
    so
    a1 * x = a2 * x + c2 - c1
    then
    a1 * x - a2 * x = c2 - c1
    then
    x * (a1 - a2) = c2 - c1
    then
    x = (c2 - c1) / (a1 - a2)
    this gives you the x value, to get the y value you put this value back into the original equation
    y = gradientOfLine1 * x + cOfLine1
    This should give you the x and y value of the intersecting point.
    p.s. Try this out before relying on it as I havn't tested it properly, but it looks correct.
    Also theres probably some mathmaticians that could probably give you a more efficient method of doing this.
    Hope this helps Michael

  • Find lines intersection

    Hi,
    what is the easiest way to find lines are intersection in one table. I tried sdo_relate/sdo_geom.sdo_relate and didn't succeed!
    Thanks
    Al

    Thank you very much for your response.
    Sdo_join require a lot of pre parameters,
    any idea what i m doing wrong in the following, i m getting wrong result for intersecting lines
    SELECT a11.id, SDO_RELATE(a11.geometry, a22.geometry, 'mask=ANYINTERACT') as RelateResult FROM a_table a11, a_table a22
    WHERE a11.id < 5 and (a22.id >6 or a22.id <8)
    and a11.id =a22.id
    order by A11.id
    your help is appreciated!

  • Looking for a way to test if the lines in a path intersect any objects?

    What i'd like to do is select an open ended path, and generate an array of all the objects that path intersects.  Here's an image to illustrate:
    The green line would be selected.  The script would run and populate an array with pointers to each yellow square the line intersects.  Does anyone have any ideas on how this can be done in javascript?  Or if it is possible at all?  Help is appreacited, thanks!

    Sure it's possible. If all of your objects-to-cross are rectangles (as in your image), it's even quite trivial.
    (15 minutes later) Oh well, perhaps not "trivial" -- I'd have to check at home whether or not I got a full-fledged rectangle intersection code. This doesn't work -- the "crossObject" function needs a bit more work.
    At least it'll give you something to look at.
    if (app.selection.length != 1)
    alert ("Wot no single path selected?");
    else
    if (!(app.selection[0] instanceof PathItem))
      alert ("Wot no path?");
    else
      allObjects = [];
      for (i=0; i<app.activeDocument.pageItems.length; i++)
       if (!app.activeDocument.pageItems[i].selected)
        allObjects.push (app.activeDocument.pageItems[i]);
      thePath = [];
      for (i=0; i<app.selection[0].pathPoints.length; i++)
       thePath.push ([ app.selection[0].pathPoints[i].anchor[0],app.selection[0].pathPoints[i].anchor[1] ] );
      app.selection[0].selected = false;
      for (i=0; i<thePath.length-1; i++)
       for (j=0; j<allObjects.length; j++)
       // only check if necessary
        if (allObjects[j].selected == true)
         continue;
        if (crossObject (thePath[i], thePath[i+1], allObjects[j]))
         allObjects[j].selected = true;
    // .. to do .. (dis doesn't work)
    // (check Liang-Barsky or Cohen-Sutherland viewport clipping)
    function crossObject (a, b, obj)
    var xl = obj.visibleBounds[1];
    var xr = obj.visibleBounds[3];
    var yt = obj.visibleBounds[0];
    var yb = obj.visibleBounds[2];
    var x1 = a[0],y1 = a[1];
    var x2 = b[0],y2 = b[1];
    // if point is inside object, it (obviously) hits
    if (x1 > xl && x1 < xr && y1 > yt && y1 < yb)
      return true;
    if (x2 > xl && x2 < xr && y2 > yt && y2 < yb)
      return true;
    return false;

  • Drawing object on the intersections point of 2 lines.

    hi guys, im very new in actionscrip , please give me some guidance.
    i'm doing this project , about 2 lines intersecting each other(the 2 lines are not always on the same position) . i try to find the intersections point using collision detection method but how do i place an object on the intersections point?
    if(line1.hitTestObject(line2)) //  so this is how we find the intersection point but we do not know how to draw/place an object on the  intersection point.

    then it's easier to calculate the intersection algebraically:
    function intersectionF(x1:Number,y1:Number,x2:Number,y2:Number,x3:Number,y3:Number,x4:Number,y4:Number):Array {
         if (x1==x2) {
              if (x3==x4) {
                   if (x1==x3) {
                        return ["line1"];
                   } else {
                        return [null];
              } else {
                   // line 1 vert, line 2 not
                   var m2:Number = (y3-y4)/(x3-x4);
                   var b2:Number = y3-m2*x3;
                   return [x1,m2*x1+b2];
         } else {
              // line 1 not vert
              if(x3==x4){
                   // line 2 vert
                   var m1:Number = (y1-y2)/(x1-x2);
                   var b1:Number = y1-m1*x1;
                   return [x3,m1*x3+b1];
              } else {
                   // line 2 not vert
                   m1 = (y1-y2)/(x1-x2);
                   b1 = y1-m1*x1;
                   m2 = (y3-y4)/(x3-x4);
                   b2 = y3-m2*x3;
                   var x:Number = (b2-b1)/(m1-m2);
                   return [x,m1*x+b1];

  • The intersection point of two lines in 3D

    How to calculate the intersection point of two lines in 3D?
    source code!

    this is actually a rather easy operation. lets look at some basic properties of lines / vectors in 3D space:
    1. If two lines intersect at a single point, then there must be exactly one plane in which the two lines are co-planar. This is pretty trivial to prove, but I won't bother here, because you can google to find out that two vectors that extend from a common point define a single plane.
    2. If you take the cross-product of two vectors, the resulting vector is guaranteed to be perpendicular to both lines (this is a basic property of a cross-product). If the two lines intersect, then this cross-product will be the normal vector to the plane in which both lines lie.
    3. Now transform (rotate) yours space such that your z-axis becomes parallel to the normal vector of that plane.
    Now, the parametric equation for a line in 3D space is this:
    (x, y, z) = (xo, yo, zo) + k(xd, yd, zd)
    After you have transformed your space, you will notice that the equation of each line will now be
    (x, y, z) = (xo, yo, zo) + k(xd, yd, 0)
    If zo is equal for both lines, then the two lines intersect. Otherwise, the two lines do not intersect.
    if the intersection exists, then to solve for it, you ignore the z coordinate, and treat it like a two dimensional system:
    (x, y) = (xo, yo) + k(xd, yd)
    you can use the basic 2D formula y - yo = m(x - xo), or y = m(x - xo) + yo
    you can calculate m = yd / xd.
    which simplifies to y = mx -mxo + yo, or 0 = mx - y + (yo - mxo)
    you now have two equations of the form Ax + By + C = 0.
    From there, you can use Cramer's rule to find the intersection of the two lines.
    It sounds kind of complicated when you read it as I have presented it, but it's actually extremely easy to write a program for, because each step is simple mathematic operation with basically no decisions involved (hence no if-structures, except at the one point where you actually need to determine if the lines intersect).
    So to reiterate, the steps required are:
    1. Check if lines are parallel. If yes, check if they are the same line, and then stop.
    2. If not parallel, cross-multiply the direction vectors of each line.
    3. Rotate your space such that z is parallel with cross-product of lines
    i. dot-product of z axis (0, 0, 1) with cross-product of lines gives angle*
    ii. cross-product of z axis (0, 0, 1) with cross-product of lines gives axis of rotation.
    iii. rotate your lines (i.e. point and direction vector) about that axis by negative of ange determined in (i).
    4. if z value of points from both lines is the different, no solution. stop.
    5. otherwise, apply Cramer's rule.
    6. done.
    * obtaining the angle of rotation with the dot product relies on the angle being less than 90 degrees, so check if z value of normal vector is + or -, and then perform dot product and cross-product on appropriate + or - z vector.
    - Adam

  • Intersecting lines

    Hi, I am the greenest newbie alive.  I am drawing with the pen tool (grrrrr not able to master) and when I have intersecting lines such as 2 s shaped curves the mid point has a gap so that it looks like someone erased part of one line.  I am using 25 pt round brush.  Also this is in CS 5.5  I have tried to highlight all the lines at once looking for some tool to change this and no luck  I searched google for lines intersecting and gaps and nothing seems to fir my problem.  Any help would be appreciate.  Loving Illustrator so far.
    Tim

  • Line Segment Intersection Checker

    Hello all,
    I am attempting to design a program that will take a set of n line segments and check which pairs of lines intersect. The lines are finite line segments, and they each have two end-points. I am supposed to be able to store a good amount of "Line Segments" into a data structure (Array, LinkedList, BinarySearchTree), etc. I am then supposed to be able to test each line segment against all of the other line segments that are read in in a text file in the format L1: (x,y),(x,y)
    I figured out how to test whether or not two finite line segments intersect, that is not the problem. What I am concerned with is the method(s) I can use to read in all of the line segments and then output the intersecting pairs of line segments in the form (L1,L2) means Line segment 1 and Line segment 2 intersect.
    I was thinking that reading the text file, I could just create an array with n slots that holds Line Segment objects (assuming I have created a Point class for keeping track of end-points), start with the first line segment in the array, and use the points from the first line segment's endpoints to all of the other line segment's endpoints in the array and check to see if they do intersect. Has anybody ever had to do something like this, and if so, what approach did you take to complete?
    Thanks in advance.

    Donojuana wrote:
    ... What I am concerned with is the method(s) I can use to read in all of the line segments and then output the intersecting pairs of line segments in the form (L1,L2) means Line segment 1 and Line segment 2 intersect.
    I was thinking that reading the text file, I could just create an array with n slots that holds Line Segment objects (assuming I have created a Point class for keeping track of end-points), start with the first line segment in the array, and use the points from the first line segment's endpoints to all of the other line segment's endpoints in the array and check to see if they do intersect.
    ...That sounds like a good plan.

  • Finding a specific point on a rendered line

    Consider the following class.
    package com.somemythicalpackage
    import java.awt.* ;
    import java.awt.event.* ;
    import javax.swing.* ;
    public class DrawrALine extends JPanel implements MouseListener{
         private Point origin, terminus ;
         public DrawrALine(){
              super() ;
         public DrawrALine(Point _origin, Point _terminus){
              this() ;
              origin = _origin ;
              terminus = _terminus ;
              addMouseListener(this) ;
              render() ;
         private void render(){
              if(origin == null || terminus == null){
                   return ;
              setBounds(origin.x, origin.y, (terminus.x - origin.x), (terminus.y - origin.y)) ;
         public void paintComponent(Graphics _g){
              _g.setColor(Color.BLACK) ;
              _g.drawLine(0, 0, getWidth(), getHeight()) ;
         public void mouseClicked(MouseEvent e){
              Point p = e.getPoint() ;
                   Here's the question, how to determine if the Point p
                   is on the line defined as being from (0:0) - (width : height)?
                   Reason being that I want the program to respond when
                   and only when the user clicks on the line, not if they
                   click elsewhere within the bounds defined by the JPanel.
         public void mouseEntered(MouseEvent e){}
         public void mouseExited(MouseEvent e){}
         public void mousePressed(MouseEvent e){}
         public void mouseReleased(MouseEvent e){}
    }In the actual application I am using this renderer class to draw lines semantically connecting objects in a graphical workspace. However, the type of connection has to be determined by the user. To that end ultimately I want to respond when the user double clicks on the line. Catching the double click is a trivial matter, but the struggle I am having is how to detemine if the user actually clicked on the line. The mouseClicked event fires anytime a mouse is clicked inside the bounds of the JPanel, and that doesn't accomplish what I need for two reasons. First, some of the bounding rectangles overlap so the user would be double clicking on the wrong connection. Secondly, it's sloppy to have the application respond because the user clicked in the same zipcode as the line.
    (Right now I would give a lot for a 10th grade geometry book)
    Regards, and thanks in advance for suggestions.
    PS

    Here's another way:
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DrawLine extends Line2D {
       private String id;
       private Point2D p1, p2;
       public DrawLine(String _id, Point2D _p1, Point2D _p2) {
          super();
          id = _id;
          p1 = _p1;
          p2 = _p2;
          //addMouseListener(this);
          //render();
       public String getId() {
          return id;
       /* (non-Javadoc)
        * @see java.awt.geom.Line2D#getX1()
       public double getX1() {
          // TODO Auto-generated method stub
          return p1.getX();
       /* (non-Javadoc)
        * @see java.awt.geom.Line2D#getY1()
       public double getY1() {
          // TODO Auto-generated method stub
          return p1.getY();
       /* (non-Javadoc)
        * @see java.awt.geom.Line2D#getP1()
       public Point2D getP1() {
          // TODO Auto-generated method stub
          return p1;
       /* (non-Javadoc)
        * @see java.awt.geom.Line2D#getX2()
       public double getX2() {
          // TODO Auto-generated method stub
          return p2.getX();
       /* (non-Javadoc)
        * @see java.awt.geom.Line2D#getY2()
       public double getY2() {
          // TODO Auto-generated method stub
          return p2.getY();
       /* (non-Javadoc)
        * @see java.awt.geom.Line2D#getP2()
       public Point2D getP2() {
          // TODO Auto-generated method stub
          return p2;
       /* (non-Javadoc)
        * @see java.awt.geom.Line2D#setLine(double, double, double, double)
       public void setLine(double arg0, double arg1, double arg2, double arg3) {
          // TODO Auto-generated method stub
       /* (non-Javadoc)
        * @see java.awt.Shape#getBounds2D()
       public Rectangle2D getBounds2D() {
         return new Rectangle2D.Double(getX1(), getY1(), getX2() - getX1(),
                                                          getY2() - getY1());
       public static void main(String[] args) {
          JFrame f = new JFrame();
          final DrawLine[] lines = new DrawLine[10];
          Point p1, p2;
          for (int i = 0; i < lines.length; i++) {
             p1 = new Point(i * 10, i * 30);
             p2 = new Point(600 - (i * 10), 400 - (i * 30));
             lines[i] = new DrawLine("l" + i, p1, p2);
          LinePanel panel = new LinePanel(lines);
          panel.addMouseListener(new MouseAdapter() {
             public void mouseClicked(MouseEvent e) {
                Point p = e.getPoint();
                System.out.println("clicked at "+p);
                Rectangle2D.Double prect = new Rectangle2D.Double((double)p.x, (double)p.y,
                                                        (double)2, (double)2);
                for (int i=0; i<lines.length; i++) {                                        
                   if (lines.intersects(prect)) {
    System.out.println("clicked on line " + lines[i].getId());
    f.getContentPane().add(panel, BorderLayout.CENTER);
    f.setSize(600, 400);
    f.setVisible(true);
    class LinePanel extends JPanel {
    private Line2D[] lines;
    public LinePanel(Line2D[] _lines) {
    super(null);
    this.lines = _lines;
    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
    for (int i=0; i<lines.length; i++) {                                        
    g2.draw(lines[i]);
    Hope this helped,
    Regards.

Maybe you are looking for

  • Ora-600 error and  DBIF_RSQL_SQL_ERROR

    Dear Team,   After Upgradation from Bw3.0b to NW07 everyday night our Database is shutting down. As per sap recommendation  We have set following db parameter on Development Server. BTREE_BITMAP_PLANS=FALSE BLOOMFILTER_ENABLED=FALSE FIXCONTROL='47283

  • Accessing files in library from adapter module

    Hello everyone! We are using XI with Netweaver 2004 and have programmed our own adapter for message transformations. After the transformation we want to validate the generated XML file with the validator from SAP XML Toolkit. Validator validator = ne

  • MISSING PLUG-IN HELP!!!

    When I try to download most things (Skype, Spotify, etc.) it says "Missing Plug-in" but not what I'm missing.  I've had this problem for about a year or so and I've emailed many support websites and asked other Mac users (who never have this problem)

  • Reverse/Delete Purchase order

    Hi All, How can we reserve the entries we made to Internal Order? There are purchase document numbers posted in the line item of Internal Order Thank you, Misbah

  • Date in Module pool !!

    Hi, I want to show a date field in Module pool Screen. I need this date field should have Search help and Auto Validation. Should i declare date field in Module pool as data: v_date(10). OR data: v_date like sy-datum.