logo
down
shadow

Convert "Cartesian coordinates" to "polar coordinates with respect to user specified origin"


Convert "Cartesian coordinates" to "polar coordinates with respect to user specified origin"

By : Jhon Micheal Domo Su
Date : November 26 2020, 01:01 AM
wish helps you I am trying convert few points in my image to polar coordinates in OpenCV. I came across function called cartToPolar which will give me polar coordinates for my points with respect to 0,0 being my origin. However I want to do this conversion by considering another point in my image as origin. Can anyone help me doing so? I came across posts which say that remap helps to shift the origin but I am not clear how it works. , Then you have to move the ref point to origin:
code :


Share : facebook icon twitter icon
How can I convert cartesian coordinates to polar coordinates using function

How can I convert cartesian coordinates to polar coordinates using function


By : Robbedpython
Date : March 29 2020, 07:55 AM
it helps some times Don't you want to use MATLAB's function CART2POL?
If you look inside it just do this:
code :
th = atan2(y,x);
r = hypot(x,y);
calabash-android: "y" and "center_y" coordinates offset by 222 when running query("*") thr

calabash-android: "y" and "center_y" coordinates offset by 222 when running query("*") thr


By : Emanuel Silivasan
Date : March 29 2020, 07:55 AM
I wish did fix the issue. It turns out that the offset appeared on this screen in the app as the keyboard was visible on the prior screen.
Clicking to generate a pop up while the keyboard was visible caused calabash to read the location of the view while the keyboard was still present, or at least in the process of disappearing, hence the "y" and "center_y" coordinates were raised a few hundred pixels.
Trying to add an image to a polar plot gives "Error: annotation_custom only works with Cartesian coordinates"

Trying to add an image to a polar plot gives "Error: annotation_custom only works with Cartesian coordinates"


By : Les Blake
Date : March 29 2020, 07:55 AM
I hope this helps . Gregor's suggestion for using the cowplot library has got me there.
Following the introduction to cowplot you can use the draw_grob function to overlay images as you like. It takes a bit of tweaking as the position changes depending on the dimensions of the plot, but its possible.
code :
# install.packages("RCurl", dependencies = TRUE)
library(RCurl)
myurl <- "http://vignette2.wikia.nocookie.net/micronations/images/5/50/German_flag.png"

# install.packages("png", dependencies = TRUE)
library(png)
img <-  readPNG(getURLContent(myurl))

# install.packages("ggplot2", dependencies = TRUE)
library(ggplot2)

ger <- grid::rasterGrob(img, interpolate=TRUE)

g <- ggplot(mtcars, aes(x=mpg, y= cyl)) + geom_line() + coord_polar()

# install.packages("cowplot", dependencies = TRUE)
library(cowplot)
h <- ggdraw(g)
## tweak this to fit your plot
h + draw_grob(ger, 0.4, 0.48, 0.07, 0.07)
How do you convert between polar coordinates and cartesian coordinates assuming north is zero radians?

How do you convert between polar coordinates and cartesian coordinates assuming north is zero radians?


By : Sachin Sangle
Date : March 29 2020, 07:55 AM
hop of those help? Typical polar coordinates 0 points to the East and they go counter-clockwise. Your coordinates start at the North and probably go clockwise. The simplest way to fix you code is to first to the conversion between angles using this formula:
code :
flippedAngle = π/2 - originalAngle
    public double bearingTo(Vector target) {
        return Math.PI/2 - (Math.atan2(target.getY() - y, target.getX() - x));
    }

    public static Vector fromPolar(double magnitude, double angle) {
        double flippedAngle = Math.PI/2 - angle;
        return new Vector(magnitude * Math.cos(flippedAngle),
                magnitude * Math.sin(flippedAngle));
    }
public class Vector {
    private final double x;
    private final double y;

    public Vector(double xIn, double yIn) {
        x = xIn;
        y = yIn;
    }

    public double getX() {
        return x;
    }

    public double getY() {
        return y;
    }

    public double getR() {
        return Math.sqrt((x * x) + (y * y));
    }

    public double getTheta() {
        return flippedAtan2(y, x);
    }

    public double bearingTo(Vector target) {
        return flippedAtan2(target.getY() - y, target.getX() - x);
    }

    public static Vector fromPolar(double magnitude, double angle) {
        double flippedAngle = flipAngle(angle);
        return new Vector(magnitude * Math.cos(flippedAngle),
                magnitude * Math.sin(flippedAngle));
    }

    // flip the angle between 0 is the East + counter-clockwise and 0 is the North + clockwise
    // and vice versa
    private static double flipAngle(double angle) {
        return Math.PI / 2 - angle;
    }

    private static double flippedAtan2(double y, double x) {
        double angle = Math.atan2(y, x);
        double flippedAngle = flipAngle(angle);
        //  additionally put the angle into [0; 2*Pi) range from its [-pi; +pi] range
        return (flippedAngle >= 0) ? flippedAngle : flippedAngle + 2 * Math.PI;
    }
}
R: Converting cartesian coordinates to polar coordinates, and then calculating distance from origin

R: Converting cartesian coordinates to polar coordinates, and then calculating distance from origin


By : Indian Caravans
Date : March 29 2020, 07:55 AM
I hope this helps you . For x-y coordinates that are in the same units (e.g. meters rather than degrees of latitude and degrees of longitude), you can use this function to get a data.frame of jump sizes and turning angles (in degrees).
Related Posts Related Posts :
  • C++ Dynamically Allocated Array; Size set by quantity of user input; Writing to a file;
  • enums to be defined as uint8_t variables in structure
  • C++ Overloaded Constructor issues
  • Fast CSV parser in C++
  • MFC GUI application rewrite - threading, messaging, Document/View, etc. Advice needed
  • How to get frame feed of a video in OpenCV?
  • saving data structure c++ to disk
  • Vector of pointers: some clarification needed
  • scaling a bitmap without losing quality
  • How to evaluate a function directly?
  • QNetworkAccessManager: How to change post data at createRequest function
  • Returning std::move of a local variable
  • Is there a fast linear SVM library with a good C++ interface?
  • What is the purpose of name mangling in C++?
  • C++ Why the void function is not working eventhough I called it?
  • How the pointer and the pointer's adress can share the same memory adress?
  • error C2220: warning treated as error - no 'object' file generated
  • exception of strcpy function in c++ console program
  • How to access USB barcode scanner data directly from USB port using C/C++ without driver
  • Under which circumstances will std::vector.clear() call a destructor?
  • Template partial specialisation and dependent names
  • best way to share data between c codes
  • C++ ignores if statement conditions
  • How to set the argv[ ] to be case-insensitive in a Win32 Console Application?
  • How to fix error "clang: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)"?
  • C++ How do I print a .txt file verbatim?
  • Creating two dimensional array of class
  • How do I correctly use COMMTIMEOUTS with OVERLAPPED IO mode reading from a Serial port
  • An assert macro which expands to static_assert when possible?
  • How to write a copyconstructor for a class which has HANDLE as a member in win32 c++ application?
  • C++ saving info such as tree in a file
  • Transforming an expression template tree
  • How to overload an operator with multiple parameters like a + b + c?
  • C++ 11 with Raspberry Pi performances
  • Make a C++ class look like a numpy array using swig
  • Postfix incrementer overloading for nested enumerated types
  • Is there a tidy way of associating metadata with functions in C++
  • QObject::installEventFilter(): Cannot filter events for objects in a different thread
  • LNK2005 error with Zxing C++
  • C++ Doubly Linked List with Pointers: Object of class isn't constructed properly
  • Using a random string generator in c++ constructor
  • What should I use instead of void as one of the alternative types in an variant?
  • C++ return value from multithreads using reference
  • How to connect multiple TCP IP clients to same server port using c++
  • Defaul compiler generates the reference operator (In C++)?
  • Unable to change directory time stamp after using FILE_FLAG_BACKUP_SEMANTICS
  • vector handling displaying output
  • WSAGetLastError returns WSAENOTSOCK - Cause?
  • C++: How to overload pow for user type?
  • C++ using arrays as multidimensional despite initalising it as 1D with pointer
  • How negate std::is_integral for use in tag dispatch?
  • Retrieve serial number from USB memory (Windows environment c++)
  • g++ error: invalid preprocessing directive #INCLUDE
  • C++ What is the std::for_each() function parameter type?
  • C++: Read individual lines from text file, sort words alphabetically
  • Saving 'this' address into a variable
  • c++ command line arguments in ubuntu terminal
  • In what order are local scoped objects destructed?
  • How to use SDL_MapRGB with SDL 2.0
  • how compiler and interpreter work in case of array declaration
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org