scbutil.c File Reference

#include <math.h>
#include <glib.h>
#include "scblog.h"
#include "scbutil.h"
Include dependency graph for scbutil.c:

Go to the source code of this file.

Defines

#define _GNU_SOURCE

Functions

static int CCW (const ScbPointPtr p0, const ScbPointPtr p1, const ScbPointPtr p2)
gboolean erscribble_is_rect_intersect (const ScbRectPtr r1, const ScbRectPtr r2)
gboolean erscribble_is_lines_intersect (const ScbPointPtr p1, const ScbPointPtr p2, const ScbPointPtr p3, const ScbPointPtr p4)

Define Documentation

#define _GNU_SOURCE

Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 28 of file scbutil.c.


Function Documentation

static int CCW ( const ScbPointPtr  p0,
const ScbPointPtr  p1,
const ScbPointPtr  p2 
) [static]

Definition at line 108 of file scbutil.c.

References _ScbPoint::x, and _ScbPoint::y.

Referenced by erscribble_is_lines_intersect().

00109 {
00110     long dx1, dx2 ;
00111     long dy1, dy2 ;
00112 
00113     dx1 = p1->x - p0->x ; dx2 = p2->x - p0->x ;
00114     dy1 = p1->y - p0->y ; dy2 = p2->y - p0->y ;
00115     /* This is basically a slope comparison: we don't do divisions because
00116     * of divide by zero possibilities with pure horizontal and pure
00117     * vertical lines.
00118     */ 
00119     return ((dx1 * dy2 > dy1 * dx2) ? 1 : -1) ;
00120 }

Here is the caller graph for this function:

gboolean erscribble_is_lines_intersect ( const ScbPointPtr  p1,
const ScbPointPtr  p2,
const ScbPointPtr  p3,
const ScbPointPtr  p4 
)

Definition at line 84 of file scbutil.c.

References CCW().

Referenced by erscribble_stroke_line_hit_test().

00088 {
00089     gboolean bRet = ((( CCW(p1, p2, p3) * CCW(p1, p2, p4)) <= 0)
00090         && (( CCW(p3, p4, p1) * CCW(p3, p4, p2)  <= 0) )) ;
00091 
00092    
00093     return bRet;
00094 }

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean erscribble_is_rect_intersect ( const ScbRectPtr  rect1,
const ScbRectPtr  rect2 
)

Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Definition at line 71 of file scbutil.c.

References _ScbRect::bottom, _ScbRect::left, _ScbRect::right, and _ScbRect::top.

Referenced by erscribble_stroke_line_hit_test(), and erscribble_stroke_point_hit_test().

00073 {
00074     // check two rectangles is intersect or not, 
00075     // these two rectangles should be normalized.
00076     return ! ( r2->left > r1->right 
00077         || r2->right < r1->left 
00078         || r2->top > r1->bottom 
00079         || r2->bottom < r1->top 
00080         );
00081 }

Here is the caller graph for this function:

Generated by  doxygen 1.6.2-20100208