Is Normal coordinates the same as Cartesian coordinates in flat space?

Let $ \gamma_v$ be the unique maximal geodesic with initial conditions $ \gamma_v(0)=p$ and $ \gamma_v'(0)=v$ then the exponential map is defined by
$ $ exp_p(v)=\gamma_v(1)$ $

If we pick any orthonormal basis,$ (e_1,…e_n)$ of $ T_pM$ then the $ x_i$ ’s, with $ x_i = pr_i◦exp^{-1}$ and $ pr_i$ the projection onto $ Re_i$ , are called normal coordinates at $ p$ .

My question is , if our manifold $ M$ is flat than does this normal coordinates coincide to what we call Cartesian coordinates ?

Cleanest functional way to iterate a 2D Grid Co-ordinates in Scala?

A Solution using nested for loops is trivial.

Here is my code to iterate over a 2D Grid in Scala using map

(1 to N) map {    i => (1 to M) map{          j => println(i + " " + j)        }    } 

This is a simple alternative to a nested loop for a 2D Grid.

How can I make this more cleaner and functional, the Braces don’t feel much functional.

The Aesthetics of the Code still looks pretty for loop like and how can I make this more cleaner.

Stokes theorem in cylindrical coordinates

Consider the following vector field in cylindrical polar components

$ $ \mathbf{F} = \frac{z}{\rho }(1-e^{-\rho /\gamma} ) \hat{\mathbf{e}}_{\rho } +\frac{z}{\rho } \hat{\mathbf{e}}_{\phi } + \phi \hat{\mathbf{e}}_{z }$ $

where γ is a constant.

Is the field F conservative?

By utilising Stokes’ theorem, evaluate the line integral of F along a closed path of area A = 2 lying on the ρ = 1 cylindrical surface (take the integral anti-clockwise as seen from outside the cylinder).

I have done the first part:

$ \frac{1}{\rho }(1-e^{-\rho /\gamma} ) \hat{\mathbf{e}}_{\phi } $

For the second part, would this be an infinitely long cylinder in the z direction of radius one with no top and bottom? If so, what would the line integral be along, as there is no closed loop. Or if using stokes, how can there be an infinite amount of flux through the sides of the cylinder? I always thought you had to have a closed surface when using stokes theorem.

Thanks.

Given a list of coordinates, find the rectangle with minimal area

A problem on leetcode asks the coder to write an algorithm to take a bunch of coordinates in the xy-plane and return the minimum area of a rectangle made from four of these coordinates (or return 0 if no four of these coordinates describe a rectangle). Admissible rectangles must have sides parallel to the coordinate axes.

I’d appreciate any comments and improvements on my code whatsoever. Of course some of them may not make sense in the context of Leetcode, and I mention such an example below. But they may still be good for me to be aware of. My code scores in the 96th percentile of solutions on speed, and 100th percentile on memory, so I don’t expect any drastic improvements. I’m posting this code because I think it’s good, and I want to get a reality check if it’s actually good or not — this is my first post on code review.

Leetcode asks the code to be a class called Solution with a method int minAreaRect(std::vector<std::vector<int>>& points), and they will test this code using this method. One effect of this is that it does no good (as far as I know) to make a constructor Solution::Solution(std::vector<std::vector<int>> &points), which would be the most natural. Therefore, for instance, I have to store points in my class as a pointer, not a reference, because I can’t know what points is at construction time.

This problem seems to call for something like a multimap from x-coordinates to the set of y-coordinates for which (x,y) is in points. I chose to implement my own “flat multimap” — since I am doing all my insertion at once, it seems better to just make a sorted vector, and so I just sorted the input vector. (The problem does not address whether I am allowed to modify the input vector — if I were not allowed to, I would copy it and sort the copy.)

My code examines all possible pairs of distinct x-coordinates, and then looks for the overlap of the y-coordinates associated with them. If the intersection of their y-coordinates has less than two elements, there is no possible rectangle to be made from this pair of x-coordinates. Therefore the code bypasses x-coordinates that have fewer than two y-coordinates associated with them.

An example test case would look like this

int main () {     std::vector<std::vector<int>> v {{0,1}, {3,2}, {5, 5}, {4, 5}, {4,4}, {2,0}, {2, 3}, {2, 2}, {1, 0}, {5, 1}, {2, 5}, {5, 2}, {2, 4}, {4, 0}};     Solution sol;     std::cout << sol.minAreaRect(v);     return 0; } 

Outputs: 2, because (2,4), (2,5), (4,4), and (4,5) describe a rectangle of area two, and that is the best we can do.

My code uses two different comparators — one which puts coordinates in lexicographic order, and one called comp_coords_fc_only which simply compares the first coordinate. The reason I made the second is so that I could call std::upper_bound(current_coord, points.end(), (*current_coord)[0], comp_coords_fc_only), which will take me to the next entry of points that has a different x-coordinate. I put this in a method called next_fc.

#include <vector> #include <algorithm> #include <iterator> #include <iostream>  using coord_it = std::vector<std::vector<int>>::iterator;  bool comp_coords_lexic(const std::vector<int> &lhs, const std::vector<int> &rhs) {     if (lhs[0] != rhs[0])         return lhs[0] < rhs[0];     return lhs[1] < rhs[1]; }  bool comp_coords_fc_only(const std::vector<int> &lhs,  const std::vector<int> &rhs) {     return (lhs[0] < rhs[0]); }  class Solution {     //"fc" = "first coordinate" and "sc" = "second coordinate" public:     int minAreaRect(std::vector<std::vector<int>>& _points) {          if (_points.size() < 4)             return 0;          std::sort(_points.begin(), _points.end(), comp_coords_lexic);          points = &_points;         int record_min_area = INT_MAX;          for (coord_it current_left_fc = _points.begin(); current_left_fc != _points.end(); current_left_fc = next_fc(current_left_fc)) {             if (has_less_than_two(current_left_fc))                 continue;              for (coord_it current_right_fc = next_fc(current_left_fc); current_right_fc != _points.end(); current_right_fc = next_fc(current_right_fc)) {                 if (has_less_than_two(current_right_fc))                     continue;                  int distance_fc = (*current_right_fc)[0] - (*current_left_fc)[0];                  if (distance_fc > record_min_area)                     continue; // need not explore first coords that are so far apart the area would necessarily be too big.                  int min_distance_sc = min_distance_shared_scs(current_left_fc, current_right_fc);                  if (min_distance_sc == 0)                     continue; // if they don't have two scs in common                  record_min_area = std::min(record_min_area, distance_fc * min_distance_sc);             } // for loop, right fc         } // for loop, left fc          if (record_min_area == INT_MAX)             return 0;         return record_min_area;     }  private:     int min_distance_shared_scs(coord_it beg_left_fc_range, coord_it beg_right_fc_range) {         // given two first coordinates (in the form of iterators pointing at the first entry         // with that first coordinate) x1 and x2, find min d(y1, y2) subject to (x1,y1), (x1, y2)         // (x2, y1), and (x2, y2) all being in the coordinate vector.          int last_match = INT_MIN; // sentinel value         int record_min_distance = INT_MAX;          auto upper_bound_left = next_fc(beg_left_fc_range), upper_bound_right = next_fc(beg_right_fc_range);         auto current_left_sc = beg_left_fc_range, current_right_sc = beg_right_fc_range;         while (current_left_sc != upper_bound_left && current_right_sc != upper_bound_right) {              if (equal_second_coord(current_left_sc, current_right_sc)) {                  if (last_match == INT_MIN) {                     last_match = (*current_left_sc)[1];                     ++current_left_sc; ++current_right_sc;                     continue;                 }                  int distance_from_last = (*current_left_sc)[1] - last_match;                 record_min_distance = std::min(record_min_distance, distance_from_last);                 last_match = (*current_left_sc)[1];                 ++current_left_sc; ++current_right_sc;                 continue;             }              if ((*current_left_sc)[1] < (*current_right_sc)[1])                 ++current_left_sc;             else                 ++current_right_sc;         } // while loop going through two ranges          if (record_min_distance == INT_MAX)             return 0;         return record_min_distance;     }      static bool equal_second_coord(coord_it it1, coord_it it2) {         return ((*it1)[1] == (*it2)[1]);     }      bool has_less_than_two(coord_it input_it) {         auto upper_bound = next_fc(input_it);         return (std::distance(input_it, upper_bound) < 2);     }      coord_it next_fc(coord_it it) {         return std::upper_bound(it, (*points).end(), *it, comp_coords_fc_only);     }      std::vector<std::vector<int>>* points; }; 

How can i retrieve coordinates from both a double click waypoint and a places waypoint – Google Maps API

I am trying to retrieve latitude and longitude the same way for both the double click waypoint and the Places Search Box waypoint. I do already get the coordinates from the double click waypoint, but i need to output the coordinates to the console log from the places waypoint aswell. How can i do so?

I have tried applying the same method for the places waypoint as i have successfully done it with the double click waypoint

<script>    // This example adds a search box to a map, using the Google Place Autocomplete   // feature. People can enter geographical searches. The search box will return a   // pick list containing a mix of places and predicted search terms.    // This example requires the Places library. Include the libraries=places   // parameter when you first load the API. For example:   // <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">    function initAutocomplete() {     var location = {lat: -33.8688, lng: 151.2195};     var map = new google.maps.Map(document.getElementById('map'), {       center: location,       zoom: 13,       mapTypeId: 'roadmap'     });      // Create the search box and link it to the UI element.     var input = document.getElementById('pac-input');     var searchBox = new google.maps.places.SearchBox(input);     map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);      // Bias the SearchBox results towards current map's viewport.     map.addListener('bounds_changed', function() {       searchBox.setBounds(map.getBounds());     });      var markers = [];     var marker = [];     // Listen for the event fired when the user selects a prediction and retrieve     // more details for that place.     searchBox.addListener('places_changed', function() {       var places = searchBox.getPlaces();        if (places.length == 0) {         return;       }        // Clear out the old markers.       markers.forEach(function(marker) {         marker.setMap(null);       });       markers = [];       // For each place, get the icon, name and location.       var bounds = new google.maps.LatLngBounds();       places.forEach(function(place) {         if (!place.geometry) {           console.log("Returned place contains no geometry");           return;           console.log(bounds);         }         /*var icon = {           url: place.icon,           size: new google.maps.Size(71, 71),           origin: new google.maps.Point(0, 0),           anchor: new google.maps.Point(17, 34),           scaledSize: new google.maps.Size(25, 25)         };*/          // Create a marker for each place.         markers.push(new google.maps.Marker({           map: map,           title: place.name,           position: place.geometry.location         }));          if (place.geometry.viewport) {           // Only geocodes have viewport.           bounds.union(place.geometry.viewport);         } else {           bounds.extend(place.geometry.location);         }       });       map.fitBounds(bounds);     });             var marker = new google.maps.Marker({       position: location,       map: map,       title: 'Hello World!'     });             // double click event   google.maps.event.addListener(map, 'dblclick', function(e) {     var positionDoubleclick = e.latLng;     marker.setPosition(positionDoubleclick);      markers.forEach(function(marker) {         marker.setMap(null);       });       markers = [];      /*console.log(e.pa.x);     console.log(e.pa.y);*/      var latitude = e.pa.y.toFixed(4);     var longtitude = e.pa.x.toFixed(4);      document.getElementById('latitude').value = latitude + String.fromCharCode(176) + ' S';     document.getElementById('longtitude').value = longtitude + String.fromCharCode(176) + ' E';   }); });   }  </script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=MY_KEY&libraries=places&callback=initAutocomplete"> </script> 

´´´

I expect to be able to return the coords for both the types of waypoints to the console.

Norm of a vector field in spherical coordinates

I think this is a very simple question; I have this complicated vector field in spherical coordinates $ (r, \theta,\phi)$ ,

$ $ \mathbf{A} = \left( A_r(r,\theta,\phi) , A_\theta(r,\theta,\phi) , A_\phi(r,\theta,\phi) \right) $ $

And I need to compute $ |A|^2$ . Instead of converting this to cartesian coordinates, which would be laborious and painful, and computing the norm as $ A_x^2 + A_y^2 + A_z^2$ , I did

$ $ |A|^2 = g_{ab} A^a A^b $ $

Where $ A^a$ are the components of the vector and $ g_{ab}$ is the metric tensor in spherical coordinates,

$ $ g_{ab} = \text{diag}(1,r^2, r^2 \sin^2 \theta) $ $

Is this correct?

Divide and conquer algorithm to find points beneath certain (x, y) coordinates

Let’s say you have a bunch of points on a cartesian plane. For a few of these points you would like to find how many of the other points lie within their (x, y) coordinate, see below for an example:

enter image description here

I’m trying to solve this for a school assignment and I haven’t been able to find any existing algorithms to do some research on. Does anyone have some existing algorithms to solve this and could list them?

Asking coordinates in a form

First time here. Nice to meet you. UX newbie here

I don’t know if this kind of question is already answered (index didn’t give me a proper answer) but I have a form with geolocation with google maps. Users can input their location through a map modal with a click or through an autocomplete input.

Problem is google is not omnipresent and some countrys have banned google and google maps api. So the idea of having only texts with info fall and I have to put some inputs with the info (street, postal code,etc.), having latitude and longitude as needed info. The question come now with 3 subsections:

  1. Which level of friction I can give to user asking with inputs about that info. It’s not something you ask in your common form.
  2. If the level of last question is too high. How good or bad is trying to guess it calculating via the info a user enter via normal inputs?
  3. And when all the previous questions falls. Even knowing a user could register out of the workplace, how bad is guessing the coordinates looking at the IP?

Thanks in advance

Checking a variable vector has equal magnitude coordinates in convex programming?

I have a program which has a variable vector $ v=(x_1,\dots,x_n)$ and I want to check if $ |x_i|=|x_j|$ at every $ 1\leq i\leq j\leq n$ .

Is it possible to do this with convex program with less than $ O(\log\log n)$ integer variables and if not what is the smallest number of integer variables needed?