# Modifying arrow length based on intersection with polygon

Background: I'm running a niche analysis for animal body part coordinates, attempting to estimate the visual field of an animal. For each frame of a video, I have extracted XY coordinates of a body part, which I have been using as an origin to draw polygons representing the visual fields of this animal (not shown here). For each row of coordinates, I am drawing multiple cone-like polygons, rotating them such that they are evenly spaced by 10°, extending outwards from the coordinate of this body part.

Difficulty with new analysis: I would like to create a separate analysis, where instead of extending polygons, I am instead extending arrows from the coordinate/origin, with their own rotations, as the animal moves about a separate polygon object. I would like the arrows/lines to be set at a fixed default length (let's say 10 'units'), except when they intersect the boundary/edges of the polygon. When an arrow would intersect, I would like to automatically adjust the length such that the tip of the intersecting arrow stops at the boundary. In Part 3 of my sample figure, you can see that when the arrows 'intersect' or contact the red polygon boundary, their length is capped at the edge of the boundary.

Main Question: Is is possible to set the length of the arrows in this dynamic way? Would it be recommended to write a statement that checks if an arrow intersects the polygon and instead change the endpoint position to the intersection coordinate?

##### 0 Comments

### Accepted Answer

##### 2 Comments

### More Answers (1)

##### 3 Comments

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!