[R] Vernier Caliper function vernier()

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Fri Apr 1 22:31:39 CEST 2005


Hi Folks,

I don't think I'm up to implementing a function for
drawing French Curves, as requested by "dream".

However, the discussion about it took me back so vividly
to the old days that, paranormally, I felt once again
the urge to ascertain magnitudes as it used to be, and
should be, done.

I have therefore implemented, and hereby donate to the
R community, a new function vernier() which implements
the Venier Caliper.

Its definition is below. Test it by entering

  vernier(pi+sqrt(.182))

By following the instructions you should find that
the result is

  x = 3 Units + 5 Tenths + 7 Hundredths

which is good enough for anyone. It generalises to
non-decimal Vernier Calipers (change the default "n=10",
but I leave it to you to work out how to deal with the
texts).

All best wishes,
Ted.

vernier <- function(x,n=10) {
  dS<-1/n; dV<-((n-1)/n)*dS
  U<-floor(x)
  plot(c(0,U+2,U+2,0,0),c(0,0,2,2,0),type="l",
       main="Vernier Caliper",xlab="",ylab="",axes=FALSE)
  lines(c(0,U+2),c(1.5,1.5))
  for(i in (0:(U+2))){lines(c(i,i),c(1.5,1.6))}
  for(i in (0:4)){lines(U+5*dS*c(i,i),c(1.5,1.575))}
  for(i in (0:20)){lines(U+dS*c(i,i),c(1.5,1.55))}
  lines(c(x,x),c(1.5,1.0))
  for(i in (1:20)){if(x+i*dV<=U+2){lines(x+c(i,i)*dV,c(1.5,1.45))}}
  text(x+1/10,1.25,"Vernier",adj=0)
  text(x+1/10,1.75,"Standard",adj=0)
  arrows(0,1.25,x,1.25)
  arrows(x,1.25,0,1.25)
  text(x/2,1.15,"x")
text(0.25,0.75,
  "1: Count the main divisions of Standard Scale for Units",adj=0)
text(0.25,0.60,
  "2: Count the minor divisions of Standard Scale for Tenths",adj=0)
text(0.25,0.45,
  "3: Count Vernier divisions till coincidence for Hundredths",adj=0)
}



--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 01-Apr-05                                       Time: 21:31:39
------------------------------ XFMail ------------------------------




More information about the R-help mailing list