cartesian

Quickly generate the cartesian product of a matrix

Let's say I have a matrix x which contains 10 rows and 2 columns. I want to generate a new matrix M that contains each unique pair of rows from x - that is, a new matrix with 55 rows and 4 columns. E.g., x <- matrix (nrow=10, ncol=2, 1:20) M <- data.frame(matrix(ncol=4, nrow=55)) k <- 1 for (i in 1:nrow(x)) for (j in i:nrow(x)) { ...

Transform a java object tree into a 2 dimension table

Hi, I'm faced to the following problem. I have a tree of java objects for which I have to export each field value into a CSV file. The result of the exportation must be similar to what we have in SQL left outer join (called cartesian product). Class author @DataField(pos = 1) String firstName; @DataField(pos = 2) String lastName; @O...

Iphone Animation - Calculation to plot Cartesian Coordinates

I have two points (x1, y1) A & (x2, y2) B. I want to animate an image from point A to point B but also have a touch event on that image. What is the best way to accomplish this? I am currently using CGPointMake to manually plot points but I want to be able to just plug in the two coordinates and have a timer loop to move the object. I...

How to generate Cartesian Coordinate (x,y) from GridBaglayout?

My question related to previous post http://stackoverflow.com/questions/2374295/how-to-fill-color-in-grid-boxes-randomly How can I get Cartesian Coordinate (x,y) of each of the boxes filled by color in Gridbaglayout. For example, if the size of the panel is 300 x 300, and the row and column is set to 5 x 5, Is there any way we will kno...

How-to map process to an Hypercube using MPI_CART

Hi, I am trying to implement bitonic sorting using MPI for 2^n processors. I would like to use an n-dimensional hypercube to do so for convenience. Using MPI_Cart_Create I can create self-organising dimensions. Doing so will maximize efficiency of my process and also reduce the number of LOC I have to spit to get it done.. Googling AND...

Polar and Cartesian calculations not completely working?

double testx, testy, testdeg, testrad, endx, endy; testx = 1; testy = 1; testdeg = atan2( testx, testy) / Math::PI* 180; testrad = sqrt(pow(testx,2) + pow(testy,2)); endx = testrad * cos(testdeg); endy = testrad * sin(testdeg); All parts of this seem to equate properly, except endx and endy should = testx and testy they do when cal...

is NATURAL JOIN any better than SELECT FROM WHERE in terms of performance ?

Today I got into a debate with my project manager about Cartesian products. He says a 'natural join' is somehow much better than using 'select from where' because the later cause the db engine to internally perform a Cartesian product but the former uses another approach that prevents this. As far as I know, the natural join syntax is no...

javascript: lat/lon, lat1/lon1, bearing, distance to x,y screen coordinates?

Hi all, how to project a lat/lon hotspot onto an 360x180 degree panorama image? Using javascript? Real data: lat/lon in decimal degrees and altitude in meters: Camera coordinates: 49.994249, 8.66539, 2 Hotspot coordinates: 49.994163, 8.665388, 2 Distance camera to hotspot in meters: 9.55 Compass bearing camera to hotspot in degrees ...

how do I convert from one cartesian system to another

2D problem: I measure the position of the 3 ends of a triangle in a cartesian system. Now i move the system (triangle) to another cartesian system and measure the position of just two ends. How can I identify the location of the 3rd end based on this data? thanks! (and sorry for the bad english as a second angle) ...

Rating the straightness of a line

I have a data set that defines a set of points on a 2-dimensional Cartesian plane. Theoretically, those points should form a line, but that line may be perfectly horizontal, perfectly vertical, and anything in between. I would like to design an algorithm that rates the 'straightness' of that line. For example, the following data sets...

IDL: Can I get the coordinates of a point on my plot's cartesian plane?

I have a plot like this: http://i.imgur.com/i9xp5.png I need the data coordinates of points in order to plot wind barbs. Now, if I wanted a wind barb to be drawn at x=100, y=20, is there a way I can obtain the data coordinates of that ( or other ) points of my plot? ...

Algorithm for arranging Cartesian points

I have few Cartesian points of the form : (x,y) where x and y both are non-negative integers. For e.g. (0,0) , (1,1), (0,1) I need an algorithm to arrange the above points in such a way that going from one point to other changes either x or y by 1. In other words, I would like to avoid diagonal movement. So, the above mentione...

How to do a rotation in R^2?

hi there! i'm stuck with a seemingly simple problem in mathematics: i need to rotate points in a 2-dimensional cartesian coordinate system, i.e. i have a point given by (x/y) and an angle gamma and i need to get the coordinates of this point if rotated by gamma... example: if x = 2 and y = 0 and the angle of rotation is 90°, the result...

Doubts in converting spherical coordinates

I'm trying to convert spherical coordinates (namely latitude and longitude from a GPS device) into Cartesian coordinates. I'm following this simple conversion derived from the polar coordinates conversion equations. Then I'm calculating the distance between the two point applying the euclidean distance but the value I'm finding is not a...

iPhone coordinate system slope-intercept of two points

Hi. I have 2 points in a UIView, but I am unable to get the correct line equation between these two points because UIView coordinate system is not cartesian. When I apply the cartesian slope of a line, I keep getting the wrong slope for the UIView coordinate system. Maybe I'm applying the identity matrix incorrectly or using the wrong id...

Most conventional method for storing XYZ data in MATLAB

Hi. I have a large amount of data to import in to MATLAB, representing location of points in cartesian space. Which of the following is the most conventional for storing and processing standard XYZ data?: OPTION #1 Store X, Y and Z coordinates as separate n * 1 vectors (possibly within a structure?). This makes: Plotting simple: plot...

flip svg coordinate system

Is there a way to flip the SVG coordinate system so that [0,0] is in the lower left instead of the upper left? ...

Algorithm for RC car...

I'm looking for an algorithm, and I have no idea where to start! I'm trying to get from point A to point B in a cartesian graph. Movement is restricted to that of a RC car: backward, forward, forward-left, and forward-right (constant turning radius; car is either turning completely, or it is not turning at all). How would I construct ...