Calculate the 8 points that define the view frustum volume

221 views
Skip to first unread message

Bruno

unread,
Nov 15, 2011, 4:39:55 AM11/15/11
to WebGL Earth Developer Group
Hello,

I'm trying to calculate the 8 points that define the view frustum
volume, i already did the algorithm that this site explains
http://knol.google.com/k/view-frustum# , this metod works if i have
the latitude and longitude in 0.0 and 0.0 .

For what i can see the position of the camera is the problem, because
the translation of the camera is always the same, its only diferente
when a zoom is made.

Can anyone give me a hint on this?
Should i try to get x,y,z coordinates of the camera with the lat and
long to use in the algorithm i show in that website?
Or anyone know another way to do this?

Sorry for my english,

Regards,
Bruno

Iain Malcolm

unread,
Nov 15, 2011, 5:50:21 AM11/15/11
to webgl...@googlegroups.com
I never properly understood this area until I got the opengl superbible, which had an excellent explanation and code samples.  There are a few good explanations around online as well, although most are linked with opengl which may or may not be relevant for you.

This site has quite a good explanation.

Bruno

unread,
Nov 15, 2011, 6:18:59 AM11/15/11
to WebGL Earth Developer Group
I already take alook at that website, but i think my problem is other.
I know what is frustum, the problem is, for me to get the 8 points of
the frustum, i need the position of the camara, the translation.
For what i saw, the webglearth moves the camara with rotations. The
position of the camera is set with the distance of the camara to the
earth, it gives +/- 0,0,-2.5 with max altitude, and then the camera
moves with latitude and longitude, in the model view matrix the
translation is always the same.

(WebGLEarth WMS Tiling requires server supports mercator Coordinate
Reference System. Requires either
* EPSG:3857 or EPSG:900913. All other CRS's will be rejected.)

For me to get the 8 points of the frustum i think i need the simples
x,y,z of the camera, that sould be in the model view matrix, should i
transforme de cordinates latitude and longitude to find them?


On 15 Nov, 10:50, Iain Malcolm <iainmalco...@gmail.com> wrote:
> I never properly understood this area until I got the opengl superbible,
> which had an excellent explanation and code samples.  There are a few good
> explanations around online as well, although most are linked with opengl
> which may or may not be relevant for you.
>
> This site <http://www.lighthouse3d.com/tutorials/view-frustum-culling/> has
> quite a good explanation.

Iain Malcolm

unread,
Nov 15, 2011, 2:18:35 PM11/15/11
to webgl...@googlegroups.com
I would have thought webglearth would know viewpoint location, but I'm not familiar with it myself.

I keep a camera location, up vector and forward vector and calculate modeview matrix from that and the
view info.  It sounds like you're trying to go the other way, which should be possible but I don't know
wht the details would be

Petr Sloup - Klokan Technologies GmbH

unread,
Nov 16, 2011, 3:44:37 AM11/16/11
to WebGL Earth Developer Group
Hi,

you can get the modelview matrix from scene.context.modelViewMatrix .
It's type is "we.math.TransformationMatrix" so you probably want to
call .getStandardMatrix() on the result to get
"goog.math.Matrix" (http://closure-library.googlecode.com/svn/docs/
class_goog_math_Matrix.html). If you multiply (0,0,0) by this matrix,
you should get position of the camera.

-----Petr SloupSoftware Engineer - WebGL Earth developer
Klokan Technologies GmbHBahnhofstrasse 9, Baar 6340, SwitzerlandTel:
+41 (0)41 511 26 12Email: in...@klokantech.comWeb: http://www.klokantech.com/

Bruno

unread,
Nov 18, 2011, 6:55:43 AM11/18/11
to WebGL Earth Developer Group
Hello,

Yes the model view matrix can be fetched with .getStandardMatrix(),
but the problem i have is,

this.context.modelViewMatrix.loadIdentity();
this.context.modelViewMatrix.rotate001(-this.camera.getRoll());
this.context.modelViewMatrix.rotate100(-this.camera.getTilt());
this.context.modelViewMatrix.rotate001(-this.camera.getHeading());
this.context.modelViewMatrix.translate(0, 0, -1 -
this.camera.getAltitude() / we.scene.EARTH_RADIUS);
this.context.modelViewMatrix.rotate100(this.camera.getLatitude());
this.context.modelViewMatrix.rotate010(-this.camera.getLongitude());

there are rotations that are not made in 0,0,0 ; the lat and long are
moving the camara to other place that is not the Translation info in
the mvm (i think).
should i do a simple p'=p*RotX and p'=p*RotY to find the new position
of the camera?
(p - position of the camera , p' - new position , RotX RotY - matrix
to rotate in X and Y axe)

should i use like proj4js to find the coordinates in x,y,z?
if i use this proj4js, the lat long heigh are in epsg:4979 (or epsg:
4326 ?) and i must convert to wsg84?

On 16 Nov, 08:44, Petr Sloup - Klokan Technologies GmbH
<sloupp...@gmail.com> wrote:
> Hi,
>
> you can get the modelview matrix from scene.context.modelViewMatrix .
> It's type is "we.math.TransformationMatrix" so you probably want to
> call .getStandardMatrix() on the result to get
> "goog.math.Matrix" (http://closure-library.googlecode.com/svn/docs/
> class_goog_math_Matrix.html). If you multiply (0,0,0) by this matrix,
> you should get position of the camera.
>
> -----Petr SloupSoftware Engineer - WebGL Earth developer
> Klokan Technologies GmbHBahnhofstrasse 9, Baar 6340, SwitzerlandTel:
> +41 (0)41 511 26 12Email: i...@klokantech.comWeb:http://www.klokantech.com/
Reply all
Reply to author
Forward
0 new messages