CGPolygonRayInter

Section: C Library Functions (3)
Updated: IRIT Version 6.0
Index Return to Main Contents
 

NAME

CGPolygonRayInter()  

SYNOPSIS

geom_lib/geomat3d.c:970

int CGPolygonRayInter(IPPolygonStruct *Pl, PointType PtRay, int RayAxes)
 

DESCRIPTION

Routine that implements "Jordan Theorem": Fire a ray from a given point and find the number of intersections of a ray with the polygon, excluding the given point Pt (start of ray) itself, if on polygon boundary. The ray is fired in +X (Axes == 0) or +Y if (Axes == 1). Only the X/Y coordinates of the polygon are taken into account, i.e. the orthogonal projection of the polygon on an X/Y parallel plane (equal to polygon itself if on X/Y parallel plane...). Note that if the point is on polygon boundary, the ray should not be in its edge direction.

Algorithm:
 1. 1.1. Set NumOfIntersection = 0;
    1.2. Find vertex V not on Ray level and set AlgState to its level (below or above the ray level). If none goto 3;
    1.3. Mark VStart = V;
 2. Do
    2.1. While State(V) == AlgState do
           2.1.1. V = V -> Pnext;
           2.1.2. If V == VStart goto 3;
    2.2. IntersectionMinX = INFINITY;
    2.3. While State(V) == ON_RAY do
           2.3.1. IntersectionMin = MIN(IntersectionMin, V -> Coord[Axes]);
           2.3.2. V = V -> Pnext;
    2.4. If State(V) != AlgState do
           2.4.1. Find the intersection point between polygon edge Vlast, V and the Ray and update IntersectionMin if lower than it.
           2.4.2. If IntersectionMin is greater than Pt[Axes] increase the NumOfIntersection counter by 1.
    2.5. AlgState = State(V);
    2.6. goto 2.2.
 3. Return NumOfIntersection;  

PARAMETERS:

Pl: To compute "Jordan Theorem" for the given ray.

PtRay: Origin of ray.

RayAxes: Direction of ray. 0 for X, 1 for Y, etc.  

FUNCTION RETURN VALUE

int: Number of intersections of ray with the polygon.

 

ORIGIN

(C) Copyright 1989/90-95 Gershon Elber, Technion, IIT


 

Index

NAME
SYNOPSIS
DESCRIPTION
PARAMETERS:
FUNCTION RETURN VALUE
ORIGIN

This document was created by man2html, using the manual pages.
Time: 07:26:37 GMT, July 20, 2024