sol12 - 12 ' - 1. #include <stdio.h> typedef struct...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
12 ןורתפל אמגוד 1 תודוקנו םירשי . #include <stdio.h> typedef struct line_t { double a; double b; } Line; typedef struct point_t { double x; double y; } Point; int doIntersect(Line l1, Line l2); Point intersectionPoint(Line l1, Line l2); int isPointOnLine(Line l, Point p); Line getLine(Point p1, Point p2); int main() { Line l1, l2, l3, l4; Point p,p1,p2; l1.a = 1; l1.b = -2; l2.a = -1; l2.b = 4; l3.a = 1; l3.b = 0; printf( "doIntersect(l1,l2)? %d\n" ,doIntersect(l1,l2)); printf( "doIntersect(l1,l3)? %d\n" ,doIntersect(l1,l3)); p = intersectionPoint(l1,l2); printf( "intersection point(l1,l2): (%g,%g)\n" ,p.x,p.y); p.x = 3; p.y = 1; printf( "point (3,1) on line l1?: %d\n" ,isPointOnLine(l1,p)); p.x = 3; p.y = 1.5; printf( "point (3,1.5) on line l1?: %d\n" ,isPointOnLine(l1,p)); p1.x = 0; p1.y = -2; p2.x = 3; p2.y = 1; l4 = getLine(p1,p2); printf( "line: %g %g\n" , l4.a, l4.b); return 0; } int doIntersect(Line l1, Line l2) { return
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/10/2010 for the course CS 463 taught by Professor Can'tsay during the Spring '09 term at Haaga - Helia University of Applied Sciences.

Page1 / 3

sol12 - 12 ' - 1. #include &lt;stdio.h&gt; typedef struct...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online