Skip to content

Instantly share code, notes, and snippets.

@alecmce
Created May 26, 2010 23:25
Show Gist options
  • Save alecmce/415218 to your computer and use it in GitHub Desktop.
Save alecmce/415218 to your computer and use it in GitHub Desktop.
var ray:Ray3D = new Ray3D(0, 0, -140, 0, 0, 100);
var sphere:Sphere3D = new Sphere3D(40, 0, 0, 0);
var alpha:Number = sphere.intersectRay(ray);
trace(alpha);
// outputs 0.6428719030100183
@alecmce
Copy link
Author

alecmce commented May 26, 2010

So... I'm starting a ray at (0,0,-140) and extending it along the z-axis only by (0,0,100), surely it hits the sphere at (0,0,-40), which should return 1. What the hell!?

@alecmce
Copy link
Author

alecmce commented May 27, 2010

The Sphere3D.intersectRay code must have been copied-and-pasted into the Sphere3D. It is fast code that contains the underlying assumption that the Ray3D's vector (i.e. the last three parameters) are normalized, which in this case, they are clearly not. Documentation? None. Inline comments in the source code? None. Waste of my time? Complete and utter. Thanks a bunch.

@timknip
Copy link

timknip commented May 27, 2010

is the output correct with normalized direction vector yes or no? If not please file a bug report http://code.google.com/p/papervision3d/issues/list Jeez.

@alecmce
Copy link
Author

alecmce commented May 27, 2010

Yes. The output is fine with a normalized vector. I've calmed down a bit now, though I'm going to have to work late because of the delay all this caused me, but I still really think that some documentation would be helpful in these circumstances. Take the matrix3D..copy(matrix3D):Matrix3D function. Which one is copied to which? Which one is returned? It's an absolutely fine and flexible API to have, but only if it's well documented. I feel like I code at less than half my normal pace just because documentation doesn't exist. As it happens, I don't document internal project code either, but I sure-as-hell document public APIs. Jeez indeed.

@timknip
Copy link

timknip commented May 27, 2010

Okay, documentation isn't what it should be. Point taken. But, its open source, so guess you simply have to live with some limitations. Can understand your frustration though, sorry ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment