You are not logged in -
nap
CSDb User Forums
Forums
>
C64 Coding
>
I'm a math retard (aka. Raytracing) :)
2005-07-02
00:48
Cybernator
Registered: Jun 2002
Posts: 154
I'm a math retard (aka. Raytracing) :)
[WRHAAAAAAAAAAAGGGGHHHHHH]
Oh, hi! ;)
I've been tracing some rays and I got my first sphere with diffuse shading on da screen. "Neat, if one can get such an ideal sphere so easily, what's left for polygons?" - that was my thought after seeing my masterpiece, but... life's always turning harsh on me. :)
Ok, when tracing polygons (let's stick to triangles for now), one needs to find the intersection with the plane in which the triangle lies. Different tutorials use different ways to describe the plane. Eg:
1. a normal and a point (this is what I use, coz it's simple. The normal is found from the triangle's vertices using crossproduct).
2. ax+by+cz+d=0 (now I really don't get this shit)
I think the ray-plane intersection works. I don't understand why I'm getting a flat shaded plane, but I can live with that for now. Now comes the test if the intersection point lies on the triangle. Again there're tons of methods. I tried one or two, but it doesn't work. I'm either doing something wrong, or I don't get the idea (is there a difference :)). I found a doc by Chris Dragan (I stripped the part about triangles and uploaded it at
http://www.geocities.com/lazeristoski/chrisd.html
).
Read it yet? Ok, let's go on. :)
So I need to find p and q, and if they and their sum are within range 0-1, the point lies on the triangle. Here goes the formula:
P-C = V1*p + V2*q
P is the intersection point (I have this from the ray-plane intersection routine)
C is a point on the triangle (I can practically take one of the 3 vertices that define the triangle)
V1 and V2 are calculated from the vertices.
So I've got everything, but p and q.
All this is well and good, but how do I calculate p and q ??? (given the above formula) :)
Chris mentions something about taking the inverse matrix, but I still have no idea.
I shouldn't have posted this, eh? Maybe I've reached the zenith of my intelligence and I'm stuck beyond this barrier? :(
When people invented math, couldn't they make it easier? ;)
2005-07-02
18:26
Cybernator
Registered: Jun 2002
Posts: 154
YEAH, who's da mathematician here? ;P
I accidentally stumbled upon
http://www.blackpawn.com/texts/pointinpoly/default.html
and... I see a triangle on my screen, and I'm damn sure it's not scan-converted. ;D
I wish I could "sleep" on the internet... :(
Heh, what a nice chat I've made to myself. ;P
2005-07-02
19:22
TDJ
Registered: Dec 2001
Posts: 1879
You must be very popular at parties ;)
2005-07-02
22:01
Copyfault
Registered: Dec 2001
Posts: 478
Hey Laze!
So are you really asking how to solve the vector-equation
p - c = v_1 * p + v_2 * q,
with p, c, v_1, v_2 lying in R^2, and p, q are real values we want to evaluate?
The answer to it is already written in the excerpt you put on your HP! You can write the above eqn like this
w = A * x,
where w := p - c is a welldefined vector in R^2, A is the matrix with v_1 as first column and v_2 as second, and x is just the vector (p, q). _IF_ A is invertible, this gives
x = A^{-1}*w.
As everything on the right handside is known, and as we want to calculate p, q which are the components of the vector x, this will solve your problem.
If you have deeper questions on these quite elementary stuff, let's swap over to email conversation, as I doubt such a topic will be of any sense here on CSDB ;))
Have a nice day (or night *grin*)
Copyfault
2005-07-03
00:39
Cybernator
Registered: Jun 2002
Posts: 154
> with p, c, v_1, v_2 lying in R^2, and p, q are real
> values we want to evaluate?
Erm... What's R^2?
> The answer to it is already written in the excerpt
> you put on your HP!
Yes I know, but read the title of this thread. 8-|
> w = A * x,
> where w := p - c is a welldefined vector in R^2,
> A is the matrix with v_1 as first column
> and v_2 as second, and x is just the vector (p, q).
> _IF_ A is invertible, this gives
> x = A^{-1}*w.
By this moment I've been suspecting, but now I'm sure... I'll never pass the math exams. :( I better go for another university. ;)
Pure analogy with real numbers. But having two variables was just confusing me heavily. Also, when speaking of inverse of a number, I usually think 256-number (number eor 255). :P
> As everything on the right handside is known[...]
It's all clear now.
> If you have deeper questions on these quite
> elementary stuff, let's swap over to email conversation,
> as I doubt such a topic will be of any sense here on
> CSDB ;))
There're more appropriate forums, but I tried CSDb coz I feel like home here. ;)
10x a lot Bjoern!
The Dark Judge wrote:
> You must be very popular at parties ;)
As a matter of fact, I'm an introvert by nature. But hey! It really depends on the company. ;)
Refresh
Subscribe to this thread:
You need to be logged in to post in the forum.
Search the forum:
Search
All forums
C64 Coding
C64 Composing
C64 Pixeling
C64 Productions
CSDb Bug Reports
CSDb Development
CSDb Discussions
CSDb Entries
CSDb Feedback
CSDb Info
CSDb moderators
CSDb Questions
Messages to moderators
Requests
for
in
Writer & text
Text
Writer
All times are CET.
Search CSDb
All
Releases
Groups
Sceners
Events
BBS
SIDs
-------
Forum
Comments
Advanced
Users Online
cba
Andy/AEG
Icon/TRIAD
Twilight/Excess/Arcade
Twoflower/ΤRIΛD
grennouille
Alakran_64
rambo/Therapy/ Resou..
Guests online: 119
Top Demos
1
Next Level
(9.7)
2
13:37
(9.7)
3
Mojo
(9.7)
4
Coma Light 13
(9.6)
5
The Demo Coder
(9.6)
6
Edge of Disgrace
(9.6)
7
What Is The Matrix 2
(9.6)
8
Uncensored
(9.6)
9
Comaland 100%
(9.6)
10
Wonderland XIV
(9.6)
Top onefile Demos
1
No Listen
(9.7)
2
Layers
(9.6)
3
Cubic Dream
(9.6)
4
Party Elk 2
(9.6)
5
Copper Booze
(9.6)
6
X-Mas Demo 2024
(9.5)
7
Dawnfall V1.1
(9.5)
8
Rainbow Connection
(9.5)
9
Onscreen 5k
(9.5)
10
Morph
(9.5)
Top Groups
1
Performers
(9.3)
2
Booze Design
(9.3)
3
Oxyron
(9.3)
4
Censor Design
(9.3)
5
Triad
(9.3)
Top Webmasters
1
Slaygon
(9.6)
2
Perff
(9.6)
3
Sabbi
(9.5)
4
Morpheus
(9.4)
5
CreaMD
(9.1)
Home
-
Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.039 sec.