# IntersectionResult
# 说明
用于表示两条线段相交计算的结果,包含是否相交、相交点以及是否共线等信息。
# 如何使用
// 定义线段的起点和终点
Vector myPosition = ObjectManager::Player()->Position();
Vector myEndPoint = myPosition.Extend(targetPosition, 500.f);
Vector enemyPosition = enemy->Position();
Vector enemyEndPoint = enemyPosition.Extend(enemyDirection, 300.f);
// 计算两条线段是否相交
IntersectionResult result = myPosition.Intersection(myEndPoint, enemyPosition, enemyEndPoint);
// 使用相交结果
if (result.Intersects)
{
// 两条线段相交,获取交点
Vector intersectionPoint = result.Point;
// 使用交点进行进一步计算
float distanceToIntersection = myPosition.Distance(intersectionPoint);
// 可以根据交点位置决定技能施放
if (distanceToIntersection < 300.f)
{
// 在交点施放技能
ObjectManager::Player()->CastSpell(eSpellSlot::E, intersectionPoint);
}
}
// 检查是否共线
if (result.IsCollinear)
{
// 两条线段共线,可能需要特殊处理
}
# Properties
属性名 | 类型 | 描述 |
---|---|---|
Intersects | bool | 两线段是否相交 |
Point | Vector | 相交点的坐标 |
IsCollinear | bool | 两线段是否共线 |