Closed Thread Icon

Topic awaiting preservation: Wraytracer & Division Pages that link to <a href="http://ozoneasylum.com/backlink?for=8650" title="Pages that link to Topic awaiting preservation: Wraytracer &amp;amp; Division" rel="nofollow" >Topic awaiting preservation: Wraytracer &amp; Division\

 
Author Thread
wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 05-13-2003 16:20

Hey!
I'm new to this forum, but I have two questions.

Firstly, I wrote this raytracer reently (members of javascript-games.org will already know...) and I was just wondering what you thought of it. Comments would be greatly appreciated! :
kimber-ja.demon.co.uk/5KWraytracer.html

[Emp edit: making link work]

Secondly, I am trying to write a program to work out pi. I know the algorithm, but I need to do it to more decimal places than javascript allows. I have managed to do this, but if I try to compute too many decimal places, I get a dr. watson error. Please help!


Thanks!

Wrayal

Go to kimber-ja.demon.co.uk and click on the link to the raytracer! It's mine!

[This message has been edited by Emperor (edited 05-13-2003).]

quisja
Paranoid (IV) Inmate

From: everywhere
Insane since: Jun 2002

posted posted 05-13-2003 16:35

A few months ago I had to write a calculator which could work with up to 60-digit integers, in VB (euch). The obvious way to structure the number there was to have an array of length 60. Then array[n] represented its value x 10^(n-1). Obviously you'd wanna modify it to work with decimal places though. Hope that gives you seem lead, I expect someone else will be able to give you more specific help.

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 05-13-2003 16:37

Yeah, I thought of that, thats how it works. Ill have a fiddle, but Im not hopeful. I was hoping to do something along the line of a distributed network like SETI or www.mersenne.org, but in javascipt. Oh well.


Wrayal

Go to kimber-ja.demon.co.uk and click on the link to the raytracer! It's mine!

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

posted posted 05-13-2003 22:43

Slime here also made a raytracer: http://www.slimeland.com/raytrace/help.html
neat stuff, there very similar

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 05-15-2003 16:52

Yeah, it is sort of similar to slimes. Iv seen his before, and I thought I would try to do what he managed. Then I finally finished it, had a look on slime's website to cpmpare...and found his new one. Its just not even funny, its unbelievable. But I dint copy any of his code (take a look at out codes, his is about a thousand times mor efficient....)
BTW, now I have written my own raytracer, can I add my own quote to the YKYHBRTLW lists?

Wrayal

Go to kimber-ja.demon.co.uk and click on the link to the raytracer! It's mine!

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

posted posted 05-15-2003 17:00

"YKYHBRTLW" <- That an acronym or frustration with the keyboard ?

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 05-15-2003 17:42

It stands for "You Know You Have Been Raytracing Too Long When", and then you add an ending. I dont know what I would add though, Im extremely lacking in wittiness...

Go to kimber-ja.demon.co.uk and click on the link to the raytracer! It's mine!

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-16-2003 07:38

I also noticed the similarity, but saw that you coded yours very differently. =) Nicely done, making it in 5K! I don't have the patience for that. =)

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 05-17-2003 16:43

Sorry slime, I nicked your css code, but it was just sort of an odd form of homage...
I think maybe someday Ill write a class structured one, but I have just started learning C++, so Ill probably write it in that.
Mine is, however, quite slow, especially towards the end. Wont matter that much if I write it in C++ and compile it though...BTW, Im only 14, how long will it be before I learn to work out all the algorithms for the shapes myself? I really want to be able to, in order to do other shapes.

Wrayal

Go to kimber-ja.demon.co.uk and click on the link to the raytracer! It's mine!

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 05-17-2003 17:00

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 05-17-2003 20:06

Thanks for the suggestion, Ill probably have a fiddle sometime today or tomorrow. But unfortunately I cant just add the figures on the end, because of the formula. It goes like this:
1-1/3+1/5-1/7+1/9-1/11+1/13......
Then multiply the answer by 4. The more calculations you do, the closer you get. Its not that good a formula, apparantly the other distributed network programs use a much better method involving tan, but mines not a serious attempt, or I would write it in a better language.
With the whole moving to C++ thing, I have just started learning C++, but I really want to learn a few last things in javascript, like objects and prototypes. If I ever get to the standard on C++ that I am on javscript, Ill tell you. But I think it is going to take a while to learn. I had a flick through a book the other day. "Polymorphism and advanced inheritance" was the title of one chapter. I feel intimidated already...

Go to kimber-ja.demon.co.uk and click on the link to the raytracer! It's mine!

InI
Paranoid (IV) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 05-18-2003 21:47

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-19-2003 08:55
quote:
BTW, Im only 14, how long will it be before I learn to work out all the algorithms for the shapes myself? I really want to be able to, in order to do other shapes.



Well, of course, age doesn't have anything to do with it. To find equations for shapes, you have to follow these steps:

1. Define the shape as an equation. (For instance, the equation for a sphere is dot_product(x-center,x-center) = radius^2, where x is the vector in space being evaluated.)

2. Plug in the parametric equation for a ray. Rays are defined as x = start + t*direction, so plug this in for x in the equation for your shape.

3. Solve for t. (This is the hard part.)

Of course, the equations for most shapes can be looked up. To do these things, you need to have a very good understanding of vectors. You often get a polynomial equation at the end, so you need to know when to apply things like the quadratic formula. Understanding parametric equations is key. Overall, however, nothing beats a fundamental understanding of how the math you do out on paper relates to the physical shapes you started with.

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 05-19-2003 09:36

Sorry slime, I didnt mean literally by age (Im not worried about that, I love mathematics, Im going to do further maths for A-level), but its just that I have never been taught the relevant stuff, and I was just wondering when I would. (I have spent considerable time recently looking at P3 books...). Writing it was hell. Id never been taught so much as 2d vectors, let alone 3d or dot products or cross products or anything. Combined with the fact that none of my friends write javascript, it resulted in a few quite frustrating hours. I think the worst must have been the cross products. Working out the code to get the ray angles just hurt. But it worked, so hey! Im happy. The other really hard bit was doing the colours. Stupidly, I started off doing the colours by hex, which I didnt understand very well. One of my last changes to it was to convert it all to the colour system it now uses. Im still not sure about the diffuse shading on the planes though...any ideas?
Thanks very much for the support, I can see me failing my end of year exams now trying to derive cones, cylinders etc.

Wrayal

Go to kimber-ja.demon.co.uk and click on the link to the raytracer! It's mine!

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 05-19-2003 13:57

wrayal:. I already reacted to your great work on http://www.javascript-games.org forum.

At your age, as a coder I felt the same frustration of being limited by my young age and thus by my limited background in Maths and Physic.

Well, in France, you'd have to wait until you are in the year before and after the A-level to be taught vectorial calculation, matrix calculation, polynomial and vectorial spaces which are quite useful to see raytracing with a more experienced eye. Obviously these domains are not a must, and the basic knowledge to understand/make raytracing is quadratic equations, vectors, matrices. These 3 domains are easy to learn by yourself, and you'll find many documentation on the net.

As InI said, code is all about logic and mystification.

here comes some links of interrest for computer graphics, maths, and raytracing:
http://polygone.flipcode.com/raytrace_tutorial.htm
http://www.flipcode.com
http://www.cfxweb.net
http://mathworld.wolfram.com
http://www.faqs.org/faqs/by-newsgroup/comp/comp.graphics.rendering.raytracing.html
http://www.faqs.org/faqs/by-newsgroup/comp/comp.graphics.algorithms.html

Mathieu "POÏ" HENRI

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 05-19-2003 14:09

Thanks poi, but unforuntely I cant go on javascript-games.org very often anymore, school blocked it simply because it had the word "game" in the tile. Irritating gits. Oh well...many of the people from that forum are on here as well, plus we have genii like slime here...

Go to kimber-ja.demon.co.uk and click on the link to the raytracer! It's mine!

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 05-19-2003 18:01

slime! I love you! (in a totally platonic way of course...) I spent a bit of today fiddling through what you told me, then realised that to get the roots of t you just shove it through the quadratic formula, legendary! Time to try and apply it to other primitives....Thankyou so much! (Why is it that virtually every topic has praise for slime somewhere in it?). You said you need things like the quadratic formula though, are there others I am going to need to learn? Its totally logical, but I had just never really thought of it. Thankyou so much! Time to work out all those other starting point formulas. Fun.

Wrayal

Go to kimber-ja.demon.co.uk and click on the link to the raytracer! It's mine!

wrayal
Bipolar (III) Inmate

From: Cranleigh, Surrey, England
Insane since: May 2003

posted posted 05-20-2003 16:07

Sorry, you are all probably totally sick of thje whole topic of raytracing, but can I just ask one more question? I sorted out deriving the formula for a sphere, but I tried applying it to a plane...and failed miserably. Do you have any tips on working out the original starting equation, like (centre-x)^2=r^2 for a sphere? Any help would be greatly appreciated!

Wrayal

Go to kimber-ja.demon.co.uk and click on the link to the raytracer! It's mine!

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-20-2003 20:57

The formula for a plane, where the plane is defined as a normal vector and a distance from the origin, can be found by using the dot product between the normal and (the point being evaluated) minus (the normal times the the distance from the origin). Draw a picture and see if you can figure out why this is the case.

« BackwardsOnwards »

Show Forum Drop Down Menu