# ProjectionInfo
# Description
A structure used to represent projection information from a point to a line segment, including whether the projection point is on the segment, the coordinates of the projection point on the segment, etc.
# How to Use
// Define the start and end points of the segment
Vector segmentStart = ObjectManager::Player()->Position();
Vector segmentEnd = segmentStart.Extend(targetPosition, 500.f);
// Calculate the projection of the target point to the segment
Vector pointToProject = enemy->Position();
ProjectionInfo projection = pointToProject.ProjectOn(segmentStart, segmentEnd);
// Use the projection result
if (projection.IsOnSegment)
{
// The projection point is on the segment
Vector projectedPoint = projection.SegmentPoint;
// Calculate the perpendicular distance from the target point to the segment
float distanceToLine = pointToProject.Distance(projectedPoint);
// Determine if the target is within skill range
if (distanceToLine <= 60.f) // Skill width is 120, radius is 60
{
// The target is within the linear skill's area of effect
ObjectManager::Player()->CastSpell(eSpellSlot::Q, segmentEnd);
}
// Calculate the relative position of the projection point on the segment
float projectionDistance = segmentStart.Distance(projectedPoint);
float segmentLength = segmentStart.Distance(segmentEnd);
float projectionPercentage = projectionDistance / segmentLength;
// Make decisions based on projection position
if (projectionPercentage > 0.7f)
{
// Target is close to the end of the segment
}
}
else
{
// The projection point is not on the segment, it might be on the extended line
Vector linePoint = projection.LinePoint;
// May need to adjust skill direction to hit the target
}
# Properties
Property | Type | Description |
---|---|---|
IsOnSegment | bool | Whether the projection point is on the segment |
LinePoint | Vector | Projection point on the line |
SegmentPoint | Vector | Projection point on the segment |