@pirireis/webglobeplugins 0.6.10 → 0.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.6.10",
3
+ "version": "0.6.11",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -55,8 +55,8 @@ void main() {
55
55
  v_limp = vec2(0.0, 0.0);
56
56
  } else {
57
57
  vec2 position;
58
- if (radius < 250.0) {
59
- position = circleLimpFromLongLatRadCenterMercatorCompass( center_position, radius, angle);
58
+ if (radius < 1200.0) {
59
+ position = circleLimpFromLongLatRadCenterMercatorCompass( center_position, radius/ cos(center_position.y), angle);
60
60
  } else {
61
61
  position = circleLimpFromLongLatRadCenterMercatorRealDistance( center_position, radius, angle);
62
62
  }
@@ -17,7 +17,7 @@ export const R = `
17
17
 
18
18
  export const PI = `
19
19
  #ifndef PI
20
- #define PI 3.1415926535897932384626433832795
20
+ #define PI 3.141592653589793
21
21
  #endif
22
22
  `;
23
23
 
@@ -111,12 +111,32 @@ vec3 circleLimpFromLongLatRadCenterCartesian3D( vec2 center, float radius, float
111
111
  // TODO: Make it precise. Y axis is not correct.
112
112
 
113
113
  export const circleLimpFromLongLatRadCenterMercatorRealDistance = PI + `
114
+ vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle) {
115
+ float ang = angle + PI / 2.0; // Shift angle to align with +x axis
116
+ float r = radius / R;
117
+ float cos_r = cos(r);
118
+ float sin_r = sin(r);
119
+
120
+ float sin_lat = sin(center.y) * cos_r + cos(center.y) * sin_r * cos(ang);
121
+ float lat = asin(sin_lat);
122
+
123
+ float delta_long = atan(sin(ang) * sin_r * cos(center.y), cos_r - sin(center.y) * sin_lat);
124
+ float longi = center.x + delta_long;
125
+
126
+ return vec2(
127
+ R * longi,
128
+ R * log(tan(PI / 4.0 + lat / 2.0))
129
+ );
130
+ }`;
131
+
132
+
133
+ export const circleLimpFromLongLatRadCenterMercatorRealDistanceOLD = PI + `
114
134
  vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radius, float angle){
115
135
  float ang = angle + PI / 2.0; // this is there because the other methods are implemented in, angle 0 is +x axis orientatation
116
- float r = radius / R;
117
- float sin_lat = sin( center.y) * cos(r) + cos(center.y)*sin(r)* cos(ang);
136
+ float r = radius / R;
137
+ float sin_lat = sin(center.y) * cos(r) + cos(center.y) * sin(r) * cos(ang);
118
138
  float lat = asin(sin_lat);
119
- float longi = center.x + atan( sin(ang) * sin(r) * cos(center.y), cos(r) - sin(center.y) * sin_lat);
139
+ float longi = center.x + atan(sin(ang) * sin(r) * cos(center.y), cos(r) - sin(center.y) * sin_lat);
120
140
  return longLatRadToMercator(vec2(longi, lat));
121
141
  }
122
142
  `;
@@ -124,23 +144,23 @@ vec2 circleLimpFromLongLatRadCenterMercatorRealDistance(vec2 center, float radiu
124
144
  // TODO: reconstruct this function
125
145
  export const circleLimpFromLongLatRadCenterMercatorRealDistancePadding = `
126
146
  vec2 circleLimpFromLongLatRadCenterMercatorRealDistancePadding(vec2 center, float radius, float angle){
127
- float radius_radian = radius / R;
147
+ float radius_radian = radius / R;
128
148
  float new_angle;
129
- if ( angle != - 1.5707963267948966192313216916398){
130
- float section = floor(angle / ( PI / 2.0)) + 1.0;
149
+ if (angle != - 1.5707963267948966192313216916398) {
150
+ float section = floor(angle / (PI / 2.0)) + 1.0;
131
151
  float lat = center.y - radius_radian * sin(angle);
132
- float scale = 1.0/abs( cos( lat ) );
133
- new_angle = atan( tan(angle) * scale );
134
- if ( section == 2.0 ){
135
- new_angle = mod( new_angle, PI );
136
- } else if ( section == 3.0 ){
137
- new_angle = new_angle + PI;
152
+ float scale = 1.0 / abs(cos(lat));
153
+ new_angle = atan(tan(angle) * scale);
154
+ if (section == 2.0) {
155
+ new_angle = mod(new_angle, PI);
156
+ } else if (section == 3.0) {
157
+ new_angle = new_angle + PI;
138
158
  }
139
159
  } else {
140
- new_angle = angle;
160
+ new_angle = angle;
141
161
  }
142
162
  float new_lat = center.y - radius_radian * sin(new_angle);
143
- float new_scale = 1.0/abs( cos( new_lat ) );
163
+ float new_scale = 1.0 / abs(cos(new_lat));
144
164
 
145
165
  vec2 center_ = longLatRadToMercator(center);
146
166
  float x = center_.x + new_scale * radius * cos(new_angle);
@@ -156,7 +176,7 @@ vec2 circleLimpFromLongLatRadCenterMercatorCompass(vec2 center, float radius, fl
156
176
  float y = -sin(angle) * radius + center_.y;
157
177
  float x = cos(angle) * radius + center_.x;
158
178
  return vec2(x, y);
159
- }`;
179
+ } `;
160
180
 
161
181
 
162
182
  // Function to interpolate between two Cartesian points using spherical interpolation (slerp)
@@ -186,7 +206,7 @@ vec2 cartesianToSpherical(vec3 point) {
186
206
  float lon = degrees(atan(point.y, point.x)); // Longitude
187
207
 
188
208
  return vec2(lat, lon);
189
- }`;
209
+ } `;
190
210
 
191
211
  // Main function to calculate an intermediate point
192
212
 
@@ -204,10 +224,10 @@ vec3 interpolateGeographicPoint(vec2 start, vec2 end, float t) {
204
224
 
205
225
  export const angleBetweenTwoPointsRadian = `
206
226
  float angleBetweenTwoPointsRadian(vec2 start_, vec2 end_) {
207
- float start_lat = log( tan( ( 1.0 - start_.y ) * PI / 2.0 ) );
208
- float end_lat = log( tan( ( 1.0 - end_.y ) * PI / 2.0 ) );
209
- float angle = atan( (end_lat - start_lat ) / (end_.x - start_.x));
210
- return angle;
227
+ float start_lat = log(tan((1.0 - start_.y) * PI / 2.0));
228
+ float end_lat = log(tan((1.0 - end_.y) * PI / 2.0));
229
+ float angle = atan((end_lat - start_lat) / (end_.x - start_.x));
230
+ return angle;
211
231
  }
212
232
  `
213
233