python,trigonometry,angle,atan2,cartesian-coordinates

The easiest and most logically way to get at this problem is using the dot-product. Try this code (I've commented practically everything): import math def dot(vA, vB): return vA[0]*vB[0]+vA[1]*vB[1] def ang(lineA, lineB): # Get nicer vector form vA = [(lineA[0][0]-lineA[1][0]), (lineA[0][1]-lineA[1][1])] vB = [(lineB[0][0]-lineB[1][0]), (lineB[0][1]-lineB[1][1])] # Get dot prod dot_prod...

c++,polar-coordinates,cartesian-coordinates

You are converting to cartesian the points which are in cartesian already. What you want is: std::cout << "Cartesian Coordinates:" << std::endl; std::cout << to_cartesian(to_polar(a)) << std::endl; std::cout << to_cartesian(to_polar(b)) << std::endl; //... Edit: using atan2 solves the NaN problem, (0, 0) is converted to (0, 0) which is fine....

matlab,surf,cartesian-coordinates

There are two problems: You need .* rather than * between your sin(6*t) and sin(5*q) since you want per element multiplication not matrix multiplication. You want q to run from 0-PI and t to run from 0-2PI This code produces the result you're looking for. [q,t] = meshgrid(linspace(0,2*pi,100),linspace(0,pi,100)); rho =...

javascript,cartesian-coordinates

Look at it in terms of a rectangle on top and one on bottom for the y. Then for the x position it will be either the same as ap1, or one to the right or the left. if(((ap1.y == ap2.y + 1) || (ap1.y == ap2.y - 1)) //...