Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trying to draw circles based on distance between points

I'm trying to draw some circles and I was sort of hoping they would intersect with some points, alas...

library(maptools)
library(plotrix)
xy <- matrix(runif(20, min = -100, max = 100), ncol = 2)
distance <- spDistsN1(xy, xy[1, ])
plot(0,0, xlim = c(-100, 100), ylim = c(-100, 100), type = "n")
points(data.frame(xy))
points(xy[1, 1], xy[1, 2], pch = 16)
draw.circle(xy[1, 1], xy[1, 2], radius = distance)

The above code does the following:

  • Create 10 random points and choose one (first) point that would serve as an "anchor".
  • Calculate distance from anchor to all other points. This will be our "radius"
  • Draw circles around anchor point using above calculated distances for radii.
  • Scratch head why circles don't intersect with points that were used to calculate radii. circles don't intersect with points used to calculate distance
like image 528
Roman Luštrik Avatar asked Jun 12 '11 14:06

Roman Luštrik


People also ask

What is the distance formula for circles?

According to the distance formula, this is √(x−0)2+(y−0)2=√x2+y2. A point (x,y) is at a distance r from the origin if and only if √x2+y2=r, or, if we square both sides: x2+y2=r2. This is the equation of the circle of radius r centered at the origin.

Can I draw a radius on Google Earth?

Click (click, don't drag) on the map at the center point of your circle (eg: Vancouver) Move your mouse until the circle radius is the distance you want (eg: 750km) Click the map again to complete the circle. In the Ruler window, click the "Save" button.

What do you call the distance between two points along a circle?

The length between two points around the circumference of a circle is an arc.


1 Answers

This is the old aspect ratio problem that comes up from time to time when people are drawing ellipses, circles, etc.

  • Drawing non-intersecting circles

Substituting MASS::eqscplot for plot (edit: or using asp=1: see ?par) appears to solve the problem.

like image 102
Ben Bolker Avatar answered Sep 28 '22 07:09

Ben Bolker