Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35026
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2018-05-15 08:15 -0700 |
| References | <e6827ca4-d196-4e91-a9de-42a8f76dfbb4@googlegroups.com> <69141c0f-bc18-4c72-acbd-83c0555f1efb@googlegroups.com> |
| Message-ID | <fe54c69d-a438-46f0-898b-e3fc38b508c0@googlegroups.com> (permalink) |
| Subject | Re: Trying to do 3D (THIRD TRY) |
| From | bit-naughty@hotmail.com |
On Tuesday, May 15, 2018 at 10:59:10 AM UTC+5:30, Leonardo Campos wrote:
> Take a look at this code.
> https://jsfiddle.net/lscoder/rcxd8rrc/
>
> I hope this help.
Bro, thanks a TON for all that - I just spent ANOTHER 2 hours or so experimenting with my code - still not working. In particular, I'm not sure what you're doing here:
function project(point) {
const [x, y, z] = point;
const perspective = fl / (fl + z);
return [x * perspective, y * perspective];
}
What does the "const [x, y, z] = point;" do? What is z's value after this statement? (I don't know what "const" is, actually...)
Just for simplicity's sake, I was trying without any focal length, in which case it's just a division by z, am I right? Is my code here correct?:
function perspproject(threedpoly) {
for (var i=0; i<3; i++) {
twodpoly[i].x = (threedpoly[i].x/threedpoly[i].z) ;
twodpoly[i].y = (threedpoly[i].y/threedpoly[i].z) ;
}
}
Also, how do you prevent the division by zero above, if z happens to be zero, ie. the triangle is sitting on the x axis?
Thanks once again for your help.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Trying to do 3D (THIRD TRY) bit-naughty@hotmail.com - 2018-05-13 12:35 -0700
Re: Trying to do 3D (THIRD TRY) Leonardo Campos <leonardoscampos@gmail.com> - 2018-05-14 22:29 -0700
Re: Trying to do 3D (THIRD TRY) bit-naughty@hotmail.com - 2018-05-15 08:15 -0700
Re: Trying to do 3D (THIRD TRY) Leonardo Campos <leonardoscampos@gmail.com> - 2018-05-15 18:10 -0700
Re: Trying to do 3D (THIRD TRY) bit-naughty@hotmail.com - 2018-05-16 05:23 -0700
Re: Trying to do 3D (THIRD TRY) Leonardo Campos <leonardoscampos@gmail.com> - 2018-05-16 21:38 -0700
Re: Trying to do 3D (THIRD TRY) bit-naughty@hotmail.com - 2018-05-16 23:18 -0700
Re: Trying to do 3D (THIRD TRY) bit-naughty@hotmail.com - 2018-05-16 23:47 -0700
Re: Trying to do 3D (THIRD TRY) Leonardo Campos <leonardoscampos@gmail.com> - 2018-05-17 01:03 -0700
Re: Trying to do 3D (THIRD TRY) Leonardo Campos <leonardoscampos@gmail.com> - 2018-05-17 00:56 -0700
Re: Trying to do 3D (THIRD TRY) bit-naughty@hotmail.com - 2018-05-15 10:48 -0700
Re: Trying to do 3D (THIRD TRY) "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-05-15 12:48 -0700
Re: Trying to do 3D (THIRD TRY) bit-naughty@hotmail.com - 2018-05-16 05:29 -0700
Re: Trying to do 3D (THIRD TRY) bit-naughty@hotmail.com - 2018-05-16 05:27 -0700
Re: Trying to do 3D (THIRD TRY) "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-05-16 23:31 +0200
Re: Trying to do 3D (THIRD TRY) bit-naughty@hotmail.com - 2018-05-16 21:11 -0700
Re: Trying to do 3D (THIRD TRY) "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-05-17 13:35 +0200
Re: Trying to do 3D (THIRD TRY) bit-naughty@hotmail.com - 2018-05-22 05:57 -0700
Re: Trying to do 3D (THIRD TRY) "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-05-22 13:50 -0700
csiph-web