天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 73|回复: 0

arx 函数

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
[code]
AcGePoint3d CGePointUtil::GetMiddlePoint( const AcGePoint3d &startPoint, const AcGePoint3d &endPoint )
{
        double x = (startPoint.x + endPoint.x) * 0.5;
        double y = (startPoint.y + endPoint.y) * 0.5;
        double z = (startPoint.z + endPoint.z) * 0.5;

        return AcGePoint3d(x, y, z);
}

AcGePoint2d CGePointUtil::GetMiddlePoint( const AcGePoint2d &startPoint, const AcGePoint2d &endPoint )
{
        double x = (startPoint.x + endPoint.x) * 0.5;
        double y = (startPoint.y + endPoint.y) * 0.5;
       
        return AcGePoint2d(x, y);
}

AcGePoint3d CGePointUtil::PolarPoint( const AcGePoint3d &basePoint, double angle, double length )
{
        double x = basePoint.x + length * cos(angle);
        double y = basePoint.y + length * sin(angle);

        return AcGePoint3d(x, y, basePoint.z);
}

AcGePoint2d CGePointUtil::PolarPoint( const AcGePoint2d &basePoint, double angle, double length )
{
        double x = basePoint.x + length * cos(angle);
        double y = basePoint.y + length * sin(angle);
       
        return AcGePoint2d(x, y);
}

AcGePoint3d CGePointUtil::RelativePoint( const AcGePoint3d& pt, double x, double y )
{
        AcGePoint3d ptReturn(pt.x + x, pt.y + y, pt.z);
        return ptReturn;
}

// 两个点是否相同
bool CGePointUtil::IsEqual( const AcGePoint3d &firstPoint, const AcGePoint3d &secondPoint, double tol /*= 1.0E-7*/ )
{
        return (fabs(firstPoint.x - secondPoint.x) < tol &&
                fabs(firstPoint.y - secondPoint.y) < tol &&
                fabs(firstPoint.z - secondPoint.z) < tol);
}

// 两个点是否相同
bool CGePointUtil::IsEqual( const AcGePoint2d &firstPoint, const AcGePoint2d &secondPoint, double tol /*= 1.0E-7*/ )
{
        return (fabs(firstPoint.x - secondPoint.x) < tol &&
                fabs(firstPoint.y - secondPoint.y) < tol);
}

// 在数组中查找某个点,返回点在数组中的索引,未找到则返回-1
int CGePointUtil::FindPoint( const AcGePoint3dArray &points, const AcGePoint3d &point, double tol /*= 1.0E-7*/ )
{
        for (int i = 0; i < points.length(); i++)
        {
                if (IsEqual(points[i], point, tol))
                {
                        return i;
                }
        }
       
        return -1;
}

// 在数组中查找某个点,返回点在数组中的索引,未找到则返回-1
int CGePointUtil::FindPoint( const AcGePoint2dArray &points, const AcGePoint2d &point, double tol /*= 1.0E-7*/ )
{
        for (int i = 0; i < points.length(); i++)
        {
                if (IsEqual(points[i], point, tol))
                {
                        return i;
                }
        }
       
        return -1;
}

// 从数组中过滤掉重复点
void CGePointUtil::FilterEqualPoints( AcGePoint3dArray &points, double tol /*= 1.0E-7*/ )
{
        for (int i = points.length() - 1; i > 0; i--)
        {
                for (int j = 0; j < i; j++)
                {
                        if (CMathUtil::IsEqual(points[i].x, points[j].x, tol) && CMathUtil::IsEqual(points[i].y, points[j].y, tol))
                        {
                                points.removeAt(i);
                                break;
                        }
                }
        }
}

// 从数组中过滤掉重复点
void CGePointUtil::FilterEqualPoints( AcGePoint3dArray &points, const AcGePoint2d &pt, double tol /*= 1.0E-7*/ )
{
        AcGePoint3dArray tempPoints;
        for (int i = 0; i < points.length(); i++)
        {
                if (CConvertUtil::ToPoint2d(points[i]).distanceTo(pt) > tol)
                {
                        tempPoints.append(points[i]);
                }
        }
       
        points = tempPoints;
}[/code]

 

 

 

 

arx 函数
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

GMT+8, 2024-11-1 10:29 , Processed in 0.113366 second(s), 28 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表