To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > General Help > Math and Physics

Reply
 
Thread Tools Display Modes
Old 02-13-2010, 08:47 PM   #1
RipX
:: www.digital-glue.com ::
 
Join Date: Jun 2002
Location: Sheffield, UK
Posts: 2,331
Question Very general question about the implementation of vectors, vertices, edges, rays etc

This is just a LARGE generalized question regarding rays (and/or line segments or edges etc) and their place in a software rendered 3d engine that is/not performing raytracing operations. I'm learning the basics and I'm the first to admit that I don't know much about this stuff so please be kind.

OK, I wondered why a parametrized line is not used instead of a ray(or are they??). I have looked around at a few cpp files around the internet and seen a couple of resources define a Ray.cpp object, one with a vertex and a vector, another used a point and a vector. I'm also new to the math behind lines and line segments, so please bare with me. I'm pretty sure that you can define an infinate line with only a normal or a vector and origin and then define intersecting points along that line to create a line segment as a subset of that infinate line. Are there any current engines implementing lines in this way, or is there a better way to go about this?

To add further complication (or simplicity?) Wikipedia says that in vector space, the end points of a line segment are often vectors, notably u -> u + v, which makes alot of sence if defining a line by vectors in space rather than intersecting an already defined, infinate line, but I cannot find any implimentation of this either which makes me wonder about the validity of my thoughts when applying this in a 3d engine and even further complication is created when looking at the Flash 3D engine, Papervision, I looked at the Ray class and it takes 6 individual number values as it's parameters and then returns them as 2 different Number3D, (the Papervision equivalent of a Vector), data types?!?

Anyway, I'd be very interested to see an implementation of something which actually uses the CORRECT way of implementing these low level parts as per their true definitions. Any help, source or some good dialog about of this kind of thing would be great.


RipX
__________________
www.digital-glue.com
RipX is offline   Reply With Quote
Old 02-16-2010, 06:42 PM   #2
Freshmaker
Junior Member
 
Join Date: Dec 2009
Posts: 15
Quote:
Originally Posted by RipX View Post
OK, I wondered why a parametrized line is not used instead of a ray(or are they??).
They are.

Quote:
a couple of resources define a Ray.cpp object
A Ray* object.

I would not do this myself as it would force explicit conversions from ray to line/segment, which is almost definitely more trouble than it's worth, imo.

Quote:
one with a vertex and a vector,
This doesn't make sense. What does a vertex have to do with a ray?

Quote:
another used a point and a vector.
There is a strong duality between a point and a vector, so this is probably the correct approach.

I would not suggest using separate types for points and vectors, however, as they differ only conceptually. Since the math for each individual type would apply to the other as well, you would write an exponentially larger number of functions to accomodate both in all combinations.

Quote:
vector and origin
Again, this is a good way to do it.

Lines, rays and segments can all be represented by:


With the the following substitution for t:

Where b represents a fixed vector which coincides with the line and a represents the fixed offset of the base of the vector.

In words, substituting any real value for t in the above equation will produce a point on the line in terms of the length of b. For a unit vector, for example, t would represent the distance from a along the line directly. Constraining t from 0 to infinity inclusive produces a point on the ray that coincides with b, and from 0 to -infinity inclusive produces a point on the ray which coincides with -b. Constraining t from [0, 1] or [-1, 0] produces a point on the line segment the length (or negative length) of b.

But you may have understood all of this already.

Quote:
the end points of a line segment are often vectors
Remember that the differences between vectors and points are only conceptual.


Quote:
Flash 3D engine, Papervision, I looked at the Ray class and it takes 6 individual number values as it's parameters and then returns them as 2 different Number3D, (the Papervision equivalent of a Vector), data types?!?
I have not seen the function, but would guess that it takes two points, one component at a time, and determines the line they form. The inconsistency between function parameters and return type is likely a poor design decision.

Converting two points to the parametric form of a line above can be done by subtracting the two points (again, remember that points and vectors are structurally the same, so this operation is possible) and substituting the vector formed for b above. In pseudocode, something like:
Actionscript Code:
p0 + t*(p1 - p0)
Freshmaker is offline   Reply With Quote
Reply

Tags
line, ray, segment, vector, vertex

Go Back   Flash Kit Community Forums > General Help > Math and Physics

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:28 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.