Announcement

Collapse
No announcement yet.

Learning GRAPHICS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gösta H. Lovgren-2
    replied
    Originally posted by John R. Heathcote View Post
    .
    I don't know what the specific AutoCAD application of the .DAT file is, but the actual drawing information is stored in the .DWG file and I'm sure contains a lot more geometry data than what you found in the .DAT file.
    Actually JR, I honestly don't remember if it was a .DAT or what but just remember it was an ASCII file. And probably what I was looking at was just one of several/many files AC used for the drawing and I thought it was just the data AC used for the Universe drawing.

    AC is a extraordinarily complex application and I did not mean to imply otherwise, only that I know it used vectors and they seem very powerful.

    =======================================
    I read part of it all the way through.
    Samuel Goldwyn
    =======================================

    Leave a comment:


  • John R. Heathcote
    replied
    Gösta,

    A single 3D vector can describe direction and magnitude (length). So it is possible, in combination with a 3D point, to define another point in space. Or one can size the vector (change its length) and locate another point in space along the line of the vector. Just one of the vector's many uses.

    The fact that AutoCAD's drawing file is vector based makes it ideal for use in modeling real world applications such as buildings, machinery, highways, etc. I don't know what the specific AutoCAD application of the .DAT file is, but the actual drawing information is stored in the .DWG file and I'm sure contains a lot more geometry data than what you found in the .DAT file.

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    Thanks the offer John. I'll probably take you up on it one day. (Us Jersey guys gotta stick together in this unforgiving world. {grin})

    BTW I was thinking a little more on those AutoCad vectors and remember looking into the .dat files for the "Universe" drawing. IIRC (long while ago) there were only a half dozen or so numbers in each data line. And not a whole lot of lines at that for such a complex drawing. I was amazed a how much use could be made from such little data using vectors.

    Leave a comment:


  • John Montenigro
    replied
    Originally posted by Gösta H. Lovgren-2 View Post
    Am using PB9, so I imagine that's a good starting point for differences. I never noticed the PBCC5 comment in the code. Not to worry about, John. Or spend any effort remedying.
    No worry! But if you take the time to download and try it, I want you to be successful running it, and I'm willing to help to whatever extent I can.

    I was only trying it out for curiousity's sake. It's not something I think I would ever have a need for myself. Flunked trigonometry over 50 years ago. Not much hope of doing any better today {sigh}.
    Funny - that's kinda why I got into this in the first place: I have no real need for GRAPHICS and never use trig, but I wanted to explore something that I was not comfortable with. -- Each month I try to give myself a "learning problem" to solve, something to make me expand my knowledge and/or skill. I may only be a hobbyist programmer, but I am determined to keep on learning.

    I was miserable in trig, too (only 40 years ago). But now I have some exposure to PB graphics, some exposure to higher math functions, and I've learned a whole lot about solving point-in-polygon problems (well for now, mostly triangles).

    If you take the time to walk through the code using the debugger, maybe you'll pick up something useful. At least, that's my reason for posting it. I try to leave a lot of comments so that if others want to modify it, they can readily see what to keep and where they can go in another direction.

    And yes, I know that at some point I'm going to have to improve my coding style... just after I learn COM and Objects (and pointers and ...)!

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    Am using PB9, so I imagine that's a good starting point for differences. I never noticed the PBCC5 comment in the code. Not to worry about, John. Or spend any effort remedying. As I said I was only trying it out for curiousity's sake. It's not something I think I would ever have a need for myself. Flunked trigonometry over 50 years ago. Not much hope of doing any better today {sigh}.

    ====================================
    "Only two things are infinite,
    the universe and human stupidity,
    and I'm not sure about the former."
    Albert Einstein (1879-1955)
    ====================================

    Leave a comment:


  • John Montenigro
    replied
    Gosta,

    I just d/l'd the zip, extracted it, opened and compiled and ran with no errors.

    I'm using PBCC5.0. If you're using an earlier compiler, you may want to edit INTERSECT1.inc and un-comment the DECLARE FUNCTION.

    That's the only problem I can imagine would cause your difficulty?????

    -John

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    Not to be a noodge John but I just dl'ed you code (.zip) and tried running it. Got a "Duplicate Name" error in Function intersect(ByVal x1 As Double, _ (inside the Include).

    The code is way too over my head for me to run it down and it's unlikely I would have any use/need for it anyway, but I thought you'd like to know.

    =======================================
    Enjoy things which are pleasant;
    that is not the evil:
    Evil is the reducing of our moral self
    to slavery by them that is.
    Thomas Carlyle
    =======================================

    Leave a comment:


  • John R. Heathcote
    replied
    John,

    I just thought when (not if) your vector light bulb came on you will experience a thrill by discovering vector properties by yourself. Vectors have so many uses in graphics and computational geometry they are well worth understanding.

    I will help anyway I can.

    Be of good cheer, have lots of fun!

    Leave a comment:


  • John Montenigro
    replied
    "When the vector light bulb comes on..." I wouldn't be holding my breath waiting on that event!!!

    Realisticly, I won't be able to start researching and reading about vectors until the Christmas/New Year's timeframe.

    But I do appreciate your encouragement, and I promise I will look into it.

    -John

    Leave a comment:


  • John R. Heathcote
    replied
    John,

    Vectors, eh? You realize what kind of trouble I'm going to create when I get into that!?!
    Now now John, don't despair, once you understand the concept of vectors, especially when you can calculate the COS of an angle between two vectors, for example, you will be off and running. Trust me on this, the vector light bulb will come on and you will wonder how you ever got along without them.

    Leave a comment:


  • Gösta H. Lovgren-2
    replied
    Originally posted by John Montenigro View Post
    Thanks JR, I appreciate the feedback and further guidance. I'm going to have to expand my To-Do list! Vectors, eh? You realize what kind of trouble I'm going to create when I get into that!?!

    -John
    Dunno anything about vectors except one thing. It's what AutoCad uses to scale its drawings. (and drawing don't get much more accurate than AutoCad). I recall one really impressive early demo (circa version II). The drawing was of the universe showing all the planets and galaxies.

    One could drill down (magnify) repeatedly until the Earth and Moon showed up. Then even further on the Moon until it showed the Lunar Lander and a "First Step For Mankind" plaque.

    When you get Vectors figured out, John, be sure to pass it along (in DDT terms, only please {grin})

    ==========================================================
    Every war when it comes, or before it comes,
    is represented not as a war but as an act of self-defense
    against a homicidal maniac.
    George Orwell
    ==========================================================

    Leave a comment:


  • John Montenigro
    replied
    Thanks JR, I appreciate the feedback and further guidance. I'm going to have to expand my To-Do list! Vectors, eh? You realize what kind of trouble I'm going to create when I get into that!?!

    -John

    Leave a comment:


  • John R. Heathcote
    replied
    John,

    In your studies you may want to become familiar with vectors and their relationship with angles. Check out any Calculus book or books on analytical geometry as there will be a discussion on vectors and their application in solving geometric problems. If you find the above types of books too dry then try to find some books on game programming. One of the advantages of the game programming books is the authors try to optimize various graphics algorithms which can be of use to you.

    One example of the value of using vectors is that you can shorten the "AngleOppSideC" function considerably while expanding your function to handle any type of triangle.

    You may also find that your line slope may fail if you try to determine the slope of a vertical line. Using vectors can help you here too.

    Good job, keep plugging away.

    Leave a comment:


  • John Montenigro
    replied
    Thanks JR and Patrice!

    PBDEX is so far beyond my abilities, it'll take till next week for me to get grounded again! But I have been studying it, and will be playing with it over the next few months.

    Meanwhile, I figured I'd post the code that I've been developing. This is scruffy, rough-edged code that I have been using to experiment with and tweak and make mistakes with, so it's not elegant. However, it is well commented, so you can tell what I was doing...

    I think that some of the stuff in the program will be of interest to many and of use to some. Please take a look at:
    http://www.powerbasic.com/support/pb...132#post302132 and let me know what you think.

    In particular, check out:
    - the "Set_(shape)_Properties" routines,
    - the "FindPointIn_(shape)_" routines,
    but especially:
    - the "AngleOppSideC" function!
    (Given only the three coordinate points for the vertices of a triangle, it solves all the other properties. I'm kinda pleased with this!)


    Thanks to all who provided feedback and guidance! Much appreciated!

    -John

    Leave a comment:


  • Patrice Terrier
    replied
    The latest PBDEX3D engine is there:
    http://www.jose.it-berater.org/smffo...p?topic=1139.0

    Leave a comment:


  • John R. Heathcote
    replied
    John,

    There is a 3D graphics engine on the "Source Code" forums called "PBDEX3D", or something similar, that has some good stuff that may interest you too. Patrice Terrier posted this 3D engine.

    Leave a comment:


  • John Montenigro
    replied
    Thanks, John, good info.

    "Barycentric coordinates allow you to determine whether a point is inside/outside a triangle without using the intrinsic trig functions to handle angles. It is very fast."

    I'm looking forward to sinking my teeth into this!

    -JohnM

    Leave a comment:


  • John R. Heathcote
    replied
    John,

    Thanks.

    Somehow I got the idea from your first post that the eventual functionality of your routines was to determine if a point is inside or outside of a triangle. But that is not what you wrote, so my apologies.

    You are correct about the definition of degenerate triangles. The thing you need to consider is the possibility of triangles that are almost degenerate, where the geometry is related to your mathematical precision. Again, if you won't be creating "bad" triangle geometry then it won't be much of a problem. But just in case you want to use this routine for something else, then degenerate triangles should be a design consideration.

    I read about the barycentric method but I don't have working PB code for it yet.
    Barycentric coordinates allow you to determine whether a point is inside/outside a triangle without using the intrinsic trig functions to handle angles. It is very fast.

    FYI I also tried the "shoot a ray and see if there's an intercept" method. Much more complex, for no perceptible gain (under these circumstances).
    Yes, for a triangle this is a bit of overkill. This method is used to determine whether a point is inside/outside a complex polygon. For example, a complex polygon shaped like a "C". Depending on the point you wish to check it may be possible to cross the boundary of the "C" by your ray more than once. The conventional wisdom is if your ray crosses the boundary an odd number of times the point is inside, even crossings, point is outside.

    A good book on graphics programming is "Visual Basic Graphics Programming" by Rod Stephens. Has lots of source code examples for VB but are easily converted to PB.

    Leave a comment:


  • John Montenigro
    replied
    Degenerate triangles? (Sounds like something from a bad novel... Or, are they areas of the ocean off the coast of Florida where degenrates disappear?) (Hey, can you tell I'm happy to not be running a fever today?)

    Actually had to look it up, I'd never come across the term.
    Mathwords.com gives the following definitions:
    "A degenerate triangle is the "triangle" formed by three collinear points. It doesn’t look like a triangle, it looks like a line segment."
    "Collinear" is defined as: "Lying on the same line."
    and "line" is defined as: "The geometric figure formed by two points. A line is the straight path connecting two points and extending beyond the points in both directions."

    Therefore, a "Degenerate triangle" is one whose three vertices all fall on the same line. Translation: a line (two points) having a third identified point.

    OK, I understand it. However, I'm not concerned about it.

    The function finds the "centroid" point. I've done some testing, and have obtained what appears to be a valid result for an isoceles triangles with equal sides in excess of 100,000 pixels and an opposite side of only 1 pixel. Also, if it's of any value, PB does PAINT the area properly with the given point... (I have to add more than 1.1 pixels to the y-coordinate in order to get PB to paint outside the shape...makes sense: line width plus a bit)

    Note that the function does not test a given point. Rather, given the triangle's three point coordinates, the function simply returns the centroid point.

    I suppose if one wanted to, they could screen the function's input parameters to ensure they aren't too small. But otherwise, the function is perfect for my needs at this time.

    I read about the barycentric method but I don't have working PB code for it yet. I did find a C version, but my C skills are minimal. It will take me awhile to translate... FYI I also tried the "shoot a ray and see if there's an intercept" method. Much more complex, for no perceptible gain (under these circumstances).

    Thanks for your comments and for stirring up the pot; I appreciate the opportunity to explore new "angles" of this problem area...

    Now, stay tuned until I get to the larger "point-in-polygon" problem...

    -John
    Last edited by John Montenigro; 10 Nov 2008, 03:36 PM. Reason: clarify two sentences

    Leave a comment:


  • John R. Heathcote
    replied
    John,

    The method you posted will probably work well enough for most applications, but you may experience trouble when your point is nearly on a triangle edge or very close to one of the verticies. If your triangles are close to being degenerate, you also may have trouble determining if the point is inside or outside. As a test try locating a point on a triangle edge or on one of the triangle verticies and see what happens.

    The best method I have found to determine if a point is inside or outside of a triangle is through the use of barycentric coordinates.

    Leave a comment:

Working...
X