area calculation

  • Thread starter Guenther Sohler
  • Start date
G

Guenther Sohler

Guest
Is there a built-in
cadence function to calculate the area of any
polygon or rectangle in cadence ?

i could do it myself but i am wondering if it already existed
 
Is there a built-in
cadence function to calculate the area of any
polygon or rectangle in cadence ?
There's such a function in the turbo toolbox, if I remember correctly.

No public SKILL function that I'm aware of, though.


Stéphane
 
see if this works for you???

(inScheme
(defun jenPolygonArea (perim "l")
(let ((ymin (apply 'min (mapcar 'cadr perim))))
(let ((area (lambda (p1 p2)
(times ((xCoord p1) - (xCoord p2))
((yCoord p1) + (yCoord p2) - ymin)))))
(let ((total (area (car (last perim)) (car perim))))
(foreach map pts perim
(when (cdr pts)
total = total + (area (car pts) (cadr pts))))
(abs total / 2.0))))))





On Oct 2, 10:40 am, "S. Badel" <stephane.ba...@REMOVETHISepfl.ch>
wrote:
Is there a built-in
cadence function to calculate the area of any
polygon or rectangle in cadence ?

There's such a function in the turbo toolbox, if I remember correctly.

No public SKILL function that I'm aware of, though.

Stéphane
 
here is a slightly more faster version. The idea is that the function
must calculate a lower bound.
but sometimes you already know a lower bound. i.e., you might know
the bbox and the bottom
of the bbox of a polygon is a lower bound for the polygon.

-jimka


;; ?ymin is any any lower bound of the polygon.
;; If you know the db polygon, you can use:
;; (jenPolygonArea d_polygon ?ymin (bottomEdge d_polygon))
;; If you only know the list of points, jenPolygonArea will
automatically
;; calculate a sufficient lower bound for you:
;; (jenPolygonArea '((0 0) (0 1) (1 0) (1 0)))
(defun jenPolygonArea (perim @key ymin "lg")
(let ((ymin (or ymin (apply 'min (mapcar 'cadr perim))))
(total 0))
(foreach map pts (cons (car (last perim)) perim)
(when (cdr pts)
(let ((p1 (car pts))
(p2 (cadr pts)))
total = total + (times ((xCoord p1) - (xCoord p2))
((yCoord p1) + (yCoord p2) -
ymin)))))
(abs total / 2.0)))
 

Welcome to EDABoard.com

Sponsor

Back
Top