• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X PCB Editor
  3. Segment Length

Stats

  • Replies 8
  • Subscribers 159
  • Views 16615
  • Members are here 0
More Content

Segment Length

eDaJun
eDaJun over 12 years ago

 Dear All,

 

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

Capture

  • Sign in to reply
  • Cancel
  • eDave
    eDave over 12 years ago

    What are the known start values/points?

    What "point" do you want returned?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • eDaJun
    eDaJun over 12 years ago

    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  

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • eDave
    eDave over 12 years ago

    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)

    )) 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • eDaJun
    eDaJun over 12 years ago
    Dear eDave,

    what will be may value for m1,x,y?
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • eDave
    eDave over 12 years ago

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

    x:y is a point on the line segment 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
>
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information