### Subversion checkout URL

You can clone with HTTPS or Subversion.

Fetching contributors…

Cannot retrieve contributors at this time

file 139 lines (94 sloc) 4.215 kb
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 ` Spatial Query - a JQuery like Javascript library for handling spatial maths A set of functions for initializing array data into spatial objects (matrix, vectors, polygons and latitude / longitude points) from which further operations may be made. Most vector and matrix operations support calculations to any dimension size. In cases where they are not supported, one of the two following cases will arise: * The function will be named _2d or _3d to indicate what dimension   the operated data should be in * The function will throw an error stating that the general case solution has not   been implemented yet. (Matrix inversion, for example) Examples: Return a vector at point x:10, y:0, z: 40. \$v([10, 0, 40]) Return a 5 element vector: \$v([10, 0, 40, 21, 32]) Take the vector at x:10, y:20 and project it on the vector at x:30 y:50, then return the magnitude of that vector. \$v([10, 20]).project_on([30, 50]).magnitude(); Take the latitude / longitude pair for Indianapolis and convert it into cartesian (WSG84) coordinates \$ll([39.7670, -86.1563]).vector() The same as above, but roundtrip convert it back to latitude / longitude. \$ll([39.7670, -86.1563]).vector().latlng() Generate a polygon \$p([[0,0], [0, 10], [10, 10], [10, 0]]) Compute the area of the polygon \$p([[0,0], [0, 10], [10, 10], [10, 0]]).area_2d() Compute the centroid point (vector) of the polygon \$p([[0,0], [0, 10], [10, 10], [10, 0]]).centroid_2d() Compute the convex hull of the polygon \$p([[0,0], [0, 10], [10, 10], [10, 0]]).convex_hull_2d() Compute the union of the given polygon with another polygon \$p([[0,0], [0, 10], [10, 10], [10, 0]]).union_2d([[5,5], [5, 7], [15, 7], [15, 5]]) Vector: \$v([x, y, z, t, etc])   -vector() -> Vector   -latlng() -> LatLng, Convert to Latitude and Longitude   -matrix() -> Matrix   -add(other_vector_or_scalar) -> Vector   -subtract(other_vector_or_scalar) -> Vector   -multiply(other_vector_or_scalar) -> Vector   -dot_product(other_vector) -> Number   -cross_product(other_vector) -> Vector if dimension greater than 2, Number if dimension == 2   -distance(other_vector) -> Number   -distance_2d_fast(other_vector) -> Number, A faster vector distance function.   -magnitude() -> Number   -norm(n) -> Number, The nth vectorm norm, defaults to 2.   -angle_between(other_vector) -> Vector   -project_onto(other_vector) -> Vector   -x(), y(), z() -> Number, Convenience functions.   -elm(i) -> Number Matrix: \$m( [[row1a, row1b, row1c], [row2a, row2b, row2c]] )   -matrix() -> Matrix   -elm(i,j) -> Number   -add(matrix_or_scalar) -> Matrix   -subtract(matrix_or_scalar) -> Matrix   -multiply(matrix_or_scalar) -> Matrix   -divide(matrix) -> Matrix   -transpose() -> Matrix   -determinant() -> Number   -inverse() -> Matrix   -rotate() NOT IMPL   -identity() -> Matrix   -normalize() NOT IMPL Polygon: \$p( [ [x1, y1], [x2, y2], [x3, y3], [x4, y4] ] )   -matrix() -> Matrix   -polygon() -> Polygon   -add_point(vector) -> Polygon   -to_point_array() -> Array   -foreach(fn) -> Polygon, Calls fn with each node inside the polygon   -point_inside_2d(vector) -> Boolean   -point_inside_fast_2d(vector) -> Boolean   -clip_2d(polygon) -> Polygon   -union_2d(polygon) -> Polygon   -subtract_2d(polygon) -> Polygon   -area_2d() -> Number   -centroid_2d() -> Vector   -centroid_3d() -> Vector   -convex_hull_2d() -> Polygon LatitudeLongitude: \$ll( [latitude, longitude, altitude] )   -vector() -> Vector, convert to WSG84 x/y/z coords   -latlng() -> LatLng   -lat(), lng(), alt() -> Number, convenience functions   -distance_to(latlng) -> Number, Uses the Vincenty eq. for mm precision   -bearing_between(latlng) -> Number   -destination_given_distance_and_bearing(distance, bearing) -> Latlng Known bugs: * Math is not my strong suit * Boolean operations on polygons are still not reliable. There are some kinks in the algorithm. * Some of the general case operations on a matrix are not yet implemented. It's because they are hard,   and I don't personally need them right now. Chris Z For work at www.indy.com Talked about at www.yeti-factory.org`
Something went wrong with that request. Please try again.