Thread: Measuring frequency of line segment intersection with triangles

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    1

    Question Measuring frequency of line segment intersection with triangles

    I have a data set of 3D line segments centered at the origin, and a “sphere” with a surface made up of really small triangles, and need to write a program to measure the frequency of intersections of these line segments with the different triangles (the line segments always intersect with the sphere somewhere; the problem is figuring out where). I'm new to programming and am starting with C, so if anyone could give some idea of how to start, it'd be very much appreciated.

  2. #2
    pwning noobs Zlatko's Avatar
    Join Date
    Jun 2009
    Location
    The Great White North
    Posts
    132
    Wow, this is the kind of question that inspires me to learn something new. I don't know how to do it, but I recall implementing a 2 space version form Robert Sedgewick's algorithm book. The idea was to see if a point in 2 space is in or out of a polygon and involved extending a horizontal line on the point to determine if it intersected a line in the polygon. For your problem, I suppose you need to determine the equation of each line, and the equation of each triangle and solve for an intersection. You'd have to narrow down the number of candidate triangles somehow or performance would really suffer.
    Last edited by Zlatko; 07-08-2009 at 07:23 AM.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    comp.graphics.algorithms Frequently Asked Questions
    5.05: How do I find the intersection of a line and a plane?

    But since the lines start at the origin, just calculate the 3D angle, and calculate directly which surface triangle it would intersect.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    pwning noobs Zlatko's Avatar
    Join Date
    Jun 2009
    Location
    The Great White North
    Posts
    132
    A good place to start is getting your verticies into memory, if they're not there already. If they are in a file, is it a binary file, ascii file, xml ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  2. Greenhand want help!
    By leereg in forum C Programming
    Replies: 6
    Last Post: 01-29-2002, 06:04 AM
  3. SSCANF help
    By mattz in forum C Programming
    Replies: 7
    Last Post: 12-10-2001, 04:53 PM
  4. Validating the contents of a char buffer
    By mattz in forum C Programming
    Replies: 3
    Last Post: 12-09-2001, 06:21 PM

Tags for this Thread