property = WithinDomain(condition=..., point=..., polygon=...).y;
In every duration where the Boolean input condition is true, the point must be within the domain defined by the polygon. The polygon is defined by a set of points polygon[:,2], where polygon[i,1] is the x-coordinate of polygon point i and polygon[i,2] is the y-coordinate. The last point of the polygon can be identical to the first point, so polygon[1,:] = polygon[end,:]. If this is not the case, the block assumes that the last point polygon[end,:] is connected implicitely to the first point polygon[1,:]. The area inside the polygon is the desired domain.
When condition is true, output y = Satisfied if the point is on or within the polygon, and y = Violated if the point is outside of the polygon. When condition is false, y = Undecided.
The block provides additionally output distance
which is the minimum distance between the point and the polygon.
If distance > 0, then point is inside of the polygon.
If distance < 0, then point is outside of the polygon.
If distance = 0, then point is on the polygon.
Violated, Undecided, and Satisfied are elements of enumeration Property.
This block is demonstrated with the following example:
The polygon and the point are dynamically displayed in the icon of the block. If the point is within the polygon, the point is displayed in green and the polygon area in grey (the grey point on the polygon marks the polygon point that is closest to the point). If the point is outside of the polygon, it is displayed in red and the polygon area in light red:
Simulating this examples results in
simulation result |
Note, that the point is outside of the domain defined by the polygon if distance < 0.