Home > Community > Forums > PCB SKILL > Segment Length

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Segment Length 

Last post Tue, May 14 2013 1:13 AM by eDaJun. 8 replies.
Started by eDaJun 06 May 2013 05:16 PM. Topic has 8 replies and 1239 views
Page 1 of 1 (9 items)
Sort Posts:
  • Mon, May 6 2013 5:16 PM

    • eDaJun
    • Top 500 Contributor
    • Joined on Fri, Jan 18 2013
    • Posts 19
    • Points 620
    Segment Length Reply

     Dear All,

     

    Can anyone help me hot to get this given point. Thanks 

    Capture

    • Post Points: 20
  • Mon, May 6 2013 6:01 PM

    • eDave
    • Top 10 Contributor
    • Joined on Sun, Jul 13 2008
    • Christchurch, 00-NZ
    • Posts 714
    • Points 15,490
    Re: Segment Length Reply

    What are the known start values/points?

    What "point" do you want returned?

    Dave Elder, Tait Communications
    • Post Points: 20
  • Mon, May 6 2013 6:12 PM

    • eDaJun
    • Top 500 Contributor
    • Joined on Fri, Jan 18 2013
    • Posts 19
    • Points 620
    Re: Segment Length Reply

    Dear eDave,

     

    The points with arrows of two segments is the one that I would like to know.
    The segments where to points are close together...
    Please see the line and the pointing arrow for the segment length i want to know. Thanks  

    • Post Points: 20
  • Mon, May 6 2013 6:48 PM

    • eDave
    • Top 10 Contributor
    • Joined on Sun, Jul 13 2008
    • Christchurch, 00-NZ
    • Posts 714
    • Points 15,490
    Re: Segment Length Reply

    OK, that's not too difficult.

    You need to calculate perpendicular lines from the two vertices then calculate the distance between the points where these lines intersect one of the segments. The following code should help you.

     

    defun( DE_linePerpendicular (m1, x, y)

     let((m2, b2)

    cond(

    (!m1, list(0, y))

    (axlGeoEqual(m1, 0), list(nil, x))

    (t, m2 = -1.0 / float(m1), b2 = y - m2 * x, list(m2, b2))

    )

    ))

     

    defun( DE_LineLineIntersect (m1, b1, m2, b2)

     let((x)

    ;  Returns x,y intersection of line

    ;     y = m1 x + b1

    ;  with line

    ;     y = m2 x + b2

    ;  Returns nil if no or infinite no of points (i.e. m1 = m2)

    ;

    ;  m1x + b1 = m2x + b2

    ;  x = (b2 - b1)/(m1 - m2)

    ;  y = m1 x + b1

    cond(

    (!m1 && !m2, nil)

    (!m1, list(b1, m2 * b1 + b2)) ; ie. x = b1 for first line (not both nil!)

    (!m2, list(b2, m1 * b2 + b1)) ; ie. x = b2 for 2nd line (not both nil!)

    (m1 == m2, nil)

    (t, x = (b2 - b1) / (m1 - m2), list(x, m1 * x + b1))

    )

    ))

     

    defun( DE_LineEquation (pt1, pt2)

     let((m, b)

    ;  Returns (m, b) s.t. y = mx + b is the equation for the line joining points (x1,y1) and (x2,y2)

    ;  Returns (nil, x) if vertical

    m = axlLineSlope(list(pt1, pt2))

    b = if(m then cadr(pt1) - m * car(pt1) else float(car(pt1)))

    list(m, b)

    )) 

    Dave Elder, Tait Communications
    • Post Points: 20
  • Tue, May 7 2013 1:14 AM

    • eDaJun
    • Top 500 Contributor
    • Joined on Fri, Jan 18 2013
    • Posts 19
    • Points 620
    Re: Segment Length Reply
    Dear eDave,

    what will be may value for m1,x,y?
    • Post Points: 20
  • Tue, May 7 2013 2:27 AM

    • eDave
    • Top 10 Contributor
    • Joined on Sun, Jul 13 2008
    • Christchurch, 00-NZ
    • Posts 714
    • Points 15,490
    Re: Segment Length Reply

    m1 is the slope of the line (given by the DE_LineEquation function).

    x:y is a point on the line segment 

    Dave Elder, Tait Communications
    • Post Points: 20
  • Wed, May 8 2013 1:46 AM

    • eDaJun
    • Top 500 Contributor
    • Joined on Fri, Jan 18 2013
    • Posts 19
    • Points 620
    Re: Segment Length Reply
    Dear eDave, Pt1 and PT2 is the startend of the segment right? x will be the start point of the segment and y is the end point right? can you give me .il of this problem on how to get this part because I having a hard time.. Thanks in advance
    • Post Points: 20
  • Mon, May 13 2013 9:11 PM

    • eDave
    • Top 10 Contributor
    • Joined on Sun, Jul 13 2008
    • Christchurch, 00-NZ
    • Posts 714
    • Points 15,490
    Re: Segment Length Reply

    See attached. The logic might not be correct but it gives you some pointers. 

    Dave Elder, Tait Communications
    • Post Points: 20
  • Tue, May 14 2013 1:13 AM

    • eDaJun
    • Top 500 Contributor
    • Joined on Fri, Jan 18 2013
    • Posts 19
    • Points 620
    Re: Segment Length Reply
    Dear eDave, Thanks for your help. the program already run now. :)
    • Post Points: 5
Page 1 of 1 (9 items)
Sort Posts:
Started by eDaJun at 06 May 2013 05:16 PM. Topic has 8 replies.