What exactly are eye space coordinates?

Perhaps the following illustration showing the relationship between the various spaces will help: Depending if you’re using the fixed-function pipeline (you are if you call glMatrixMode(), for example), or using shaders, the operations are identical – it’s just a matter of whether you code them directly in a shader, or the OpenGL pipeline aids in … Read more

Calculating the angle between two lines without having to calculate the slope? (Java)

The atan2 function eases the pain of dealing with atan. It is declared as double atan2(double y, double x) and converts rectangular coordinates (x,y) to the angle theta from the polar coordinates (r,theta) So I’d rewrite your code as public static double angleBetween2Lines(Line2D line1, Line2D line2) { double angle1 = Math.atan2(line1.getY1() – line1.getY2(), line1.getX1() – … Read more

Converting 3D position to 2d screen position [r69!]

I’ve written for my project the following function; it receives an THREE.Object3D instance and a camera as a parameters and returns the position on the screen. function toScreenPosition(obj, camera) { var vector = new THREE.Vector3(); var widthHalf = 0.5*renderer.context.canvas.width; var heightHalf = 0.5*renderer.context.canvas.height; obj.updateMatrixWorld(); vector.setFromMatrixPosition(obj.matrixWorld); vector.project(camera); vector.x = ( vector.x * widthHalf ) + widthHalf; … Read more

How to find the element’s x center coordinates and related window offset

You have to use offset() to get the top and left position, then add half of the height() and width() values to them. That gives the center coordinates. var $this = $(this); var offset = $this.offset(); var width = $this.width(); var height = $this.height(); var centerX = offset.left + width / 2; var centerY = … Read more

Calculating bearing between two CLLocationCoordinate2Ds

Here the code modified with the changes suggested by Oren Trutner and from myself: #define degreesToRadians(x) (M_PI * x / 180.0) #define radiansToDegrees(x) (x * 180.0 / M_PI) – (float)getHeadingForDirectionFromCoordinate:(CLLocationCoordinate2D)fromLoc toCoordinate:(CLLocationCoordinate2D)toLoc { float fLat = degreesToRadians(fromLoc.latitude); float fLng = degreesToRadians(fromLoc.longitude); float tLat = degreesToRadians(toLoc.latitude); float tLng = degreesToRadians(toLoc.longitude); float degree = radiansToDegrees(atan2(sin(tLng-fLng)*cos(tLat), cos(fLat)*sin(tLat)-sin(fLat)*cos(tLat)*cos(tLng-fLng))); if (degree … Read more

Validate latitude and longitude

From MSDN http://msdn.microsoft.com/en-us/library/aa578799.aspx Latitude measures how far north or south of the equator a place is located. The equator is situated at 0°, the North Pole at 90° north (or 90°, because a positive latitude implies north), and the South Pole at 90° south (or –90°). Latitude measurements range from 0° to (+/–)90°. Longitude measures … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)