Xplace_for_ICCAD/thirdparty/flute/dist.cpp

48 lines
835 B
C++
Raw Permalink Normal View History

2022-10-20 22:46:17 +08:00
#include "global.h"
namespace Flute {
/*********************************************************************/
/*
Return the Manhattan distance between two points
*/
long dist(
Point p,
Point q
)
{
long dx, dy;
dx = (p.x) - (q.x);
if( dx < 0 ) dx = -dx;
dy = (p.y) - (q.y);
if( dy < 0 ) dy = -dy;
return dx + dy;
}
/*********************************************************************/
/*
Return the Manhattan distance between two points
*/
long dist2(
Point* p,
Point* q
)
{
long dx, dy;
dx = (p->x) - (q->x);
if( dx < 0 ) dx = -dx;
dy = (p->y) - (q->y);
if( dy < 0 ) dy = -dy;
return dx + dy;
}
/*********************************************************************/
/*********************************************************************/
} // namespace Flute