[R-sig-teaching] plot an angle of 450 degrees and adding a circular arrow to it
Albyn Jones
jones at reed.edu
Mon Oct 20 17:17:52 CEST 2014
Here is a quickly written and barely tested function. You might want to
add a final position vector,
color, lwd, lty, etc. It assumes the angle is given in degrees, and checks
the sign of the angle to draw
in the correct direction.
albyn
=====================================================================
DrawAngle <- function(theta,r=1){
# assumes angles given in degrees, not radians
theta <- 2*pi*theta/360
plot(0,0, xlim=c(-2,2),ylim=c(-2,2))
abline(h=0)
abline(v=0)
sgn <- 1
if(theta <0) {
sgn <- -1
theta <- -theta
}
Theta <- sgn*seq(0,theta,.01)
if(theta > 2*pi) r <- seq(1,1.1,along.with=Theta)
x <- r*cos(Theta)
y <- r*sin(Theta)
lines(x,y)
n <- length(x)
arrows(x[n-1],y[n-1],x[n],y[n])
}
On Mon, Oct 20, 2014 at 1:47 AM, Steven Stoline <sstoline at gmail.com> wrote:
> Dear All:
>
> I am wondering if someone can show me how to plot an angles around the
> center of a unit circle with x-y vertices added to it.
>
> Also how to add arrows showing the size and the direction of angle(s).
>
> Examples: 135 degrees and 450 degrees angles.
>
> with many thanks
> Steven
>
> --
> Steven M. Stoline
> 1123 Forest Avenue
> Portland, ME 04112
> sstoline at gmail.com
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-teaching at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
>
[[alternative HTML version deleted]]
More information about the R-sig-teaching
mailing list