Skip to content

Instantly share code, notes, and snippets.

@reox
Created March 4, 2016 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reox/f148f898f342d75d7fa7 to your computer and use it in GitHub Desktop.
Save reox/f148f898f342d75d7fa7 to your computer and use it in GitHub Desktop.
Kreissegment Verhalten von Sehnenlänge und Segmenthöhe
radius <- function(h, s){
# Abbruchbedingung
h <- ifelse(h > s/2, NaN, h)
n <- ((4 * h^2) + s^2) / (8 * h)
return( n )
}
library(ggplot2)
p <-ggplot(data.frame(x = c(0.0, 20)), aes(x))
plot(
p + stat_function(fun=radius, aes(color="10"), args=list(s=10), n = 100000)
+ stat_function(fun=radius, aes(color="20"), args=list(s=20), n = 100000)
+ stat_function(fun=radius, aes(color="30"), args=list(s=30), n = 10000)
+ stat_function(fun=radius, aes(color="40"), args=list(s=40), n = 10000)
+ scale_y_continuous(limits = c(0, 200))
+ ylab("Radius [mm]")
+ xlab("Height of Segment [mm]")
+ guides(color=guide_legend(title="Kreissehne [mm]"))
)
@reox
Copy link
Author

reox commented Mar 4, 2016

rplot01

For what is it?
I want to build a device to measure the radius of a surface by using the circular segment formular. Two pins in the distance of s and a moveable center pin will be put on the surface. while the to pins in distance s are fixed, the center will move the distance h. With this formular you can calculate the radius.

It is nice to see, that for large radii, a very small measuring error produce a much different radius. but for a radius in the range of 2*s, it is quite easy to measure it (even if the accuracy is small)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment