-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|535|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- Socoder -> Cobra -> Circle / triangle maths Posted : Saturday, 23 January 2010, 20:52 HoboBen Given the co-ordinates of two points, and an angle, I'm trying to find the third. It's not working - can someone check my maths? Perhaps I'm wrong to assume a right-angle in step 2?  Here's my implementation... Function TransformedX(svg:^svgs, pt: ^svgPoints, zoom: Real=1.0, offsetx: Integer=0) : Integer ; export Var x: Integer a, b, Bg, b2: Real Begin b = Sqrt( ((pt.x - svg.xorigin)^2) + ((pt.y - svg.yorigin)^2) ) svg.angle = svg.angle mod 360 Bg = (180 - svg.angle) / 2 If Sin(Bg) <> 0 then a = (b/Sin(Bg)) * Sin(svg.angle) Else a = 0 Endif b2 = a * Sin(Bg) x = pt.x + b2 result = ToReal(x + svg.xorigin + svg.xoffset + offsetx) * zoom * svg.scale End Function TransformedY(svg:^svgs, pt: ^svgPoints, zoom: Real=1.0, offsety: Integer=0) : Integer ; export Var y: Integer a, b, Bg, c2: Real Begin b = Sqrt( ((pt.x - svg.xorigin)^2) + ((pt.y - svg.yorigin)^2) ) svg.angle = svg.angle mod 360 Bg = (180 - svg.angle) / 2 If Sin(Bg) <> 0 then a = (b/Sin(Bg)) * Sin(svg.angle) Else a = 0 Endif c2 = a * Sin((90 - Bg)) y = pt.y + c2 result = ToReal(y + svg.yorigin + svg.yoffset + offsety) * zoom * svg.scale End --v -=-=-   Posted : Saturday, 23 January 2010, 21:08 Scherererer Why not use polar coordinates? assume the point A is the origin (so you may have to offset your values of x and y before and after the transformation). Going to polar:: r = sqrt(x^2+y^2) theta = arctan(y/x) ** you may have to use atan2 ** Coming back from polar:: x = r*cos(theta) y = r*sin(theta) so basically, convert it to polar, you'll get a value for r and theta for the point C with respect to the point A. Then add the angle A to theta, convert back to cartesian coordinates, and you've got the location for point B. again, if A isn't located at the origin, then you'll need to offset the values (just do C.x -= A.x, C.y -= A.y) and then unoffset them when you convert back to cartesian (B.x + A.x, B.y += A.y) -=-=- YouTube Twitter Computer Science Series: Logic (pt1) (part 2) (part 3) 2's Complement Mathematics: Basic Differential Calculus Posted : Saturday, 23 January 2010, 22:35 HoboBen Thanks very much! I had to read up a lot on polar coordinates, but it seems to have done the trick! Function TransformedX(svg:^svgs, pt: ^svgPoints, zoom: Real=1.0, offsetx: Integer=0) : Integer ; export Var x: Integer theta, r, rotation: Real Begin r = Sqrt( ((pt.x - svg.xorigin)^2) + ((pt.y - svg.yorigin)^2) ) theta = Atan(ToReal(pt.y) / ToReal(pt.x)) rotation = svg.angle x = r * Cos(theta + rotation) If KeyDown(VK_SPACE) then LogMsg(svgLog, (""+svg.angle+", t: "+(theta)+", r: "+rotation)) result = ToReal(x + svg.xorigin + svg.xoffset + offsetx) * zoom * svg.scale End Function TransformedY(svg:^svgs, pt: ^svgPoints, zoom: Real=1.0, offsety: Integer=0) : Integer ; export Var y: Integer theta, r, rotation: Real Begin r = Sqrt( ((pt.x - svg.xorigin)^2) + ((pt.y - svg.yorigin)^2) ) theta = Atan(ToReal(pt.y) / ToReal(pt.x)) rotation = svg.angle y = r * Sin(theta + rotation) result = ToReal(y + svg.yorigin + svg.yoffset + offsety) * zoom * svg.scale End --v -=-=-   