【初心者向け】「観測者問題」のあっけない解決方法?

所謂「**観測者問題**」については、私もこれまで色々頭を悩ませてきました。しかし実はプログラム的にはあっけない解決方法があったんです。
#均等尺(<font color=blue>Even scale</font>)の場合
**原型**
![Rplot01.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/597772/85b74587-e211-267f-c3aa-085d6b6770c5.png)

```R
c0<-seq(0,pi*2,length=61)
cx<-cos(c0)
cy<-sin(c0)
plot(cx,cy,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="Even Scale",xlab="Cos(θ)",ylab="Sin(θ)i",col=rgb(0,1,0))
par(new=T)
plot(cx*0.9,cy*0.9,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*0.8,cy*0.8,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*0.7,cy*0.7,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*0.6,cy*0.6,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*0.5,cy*0.5,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*0.4,cy*0.4,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*0.3,cy*0.3,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*0.2,cy*0.2,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*0.1,cy*0.1,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*1.9,cy*1.9,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*1.8,cy*1.8,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*1.7,cy*1.7,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*1.6,cy*1.6,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*1.5,cy*1.5,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*1.4,cy*1.4,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*1.3,cy*1.3,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*1.2,cy*1.2,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*1.1,cy*1.1,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))

abline(h=0,col=rgb(1,0,0))
abline(v=0,col=rgb(1,0,0))

# 凡例を書き添える 。
legend("topright", legend=c("y=Cos(θ)+Sin(θ)i","x=y=0"), lty =c(1,1),col=c(rgb(0,1,0),rgb(1,0,0)))
```
**関数化**(<font color=blue>見た目は同じ</font>)
![Rplot03.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/597772/aa6126bc-b1ff-b81f-b3c3-53baed1fe6a0.png)

```R
even_scale00<-function(inbetween){
c0<-seq(0,pi*2,length=61)
cx<-cos(c0)
cy<-sin(c0)
plot(cx*(1.0+inbetween),cy*(1.0+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="Even Scale",xlab="Cos(θ)",ylab="Sin(θ)i",col=c(200,200,200))
par(new=T)
plot(cx,cy,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="Cos(θ)",ylab="",col=rgb(0,1,0))
par(new=T)
plot(cx*(0.9+inbetween),cy*(0.9+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(0.8+inbetween),cy*(0.8+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(0.7+inbetween),cy*(0.7+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(0.6+inbetween),cy*(0.6+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(0.5+inbetween),cy*(0.5+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(0.4+inbetween),cy*(0.4+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(0.3+inbetween),cy*(0.3+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(0.2+inbetween),cy*(0.2+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(0.1+inbetween),cy*(0.1+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(1.9+inbetween),cy*(1.9+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(1.8+inbetween),cy*(1.8+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(1.7+inbetween),cy*(1.7+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(1.6+inbetween),cy*(1.6+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(1.5+inbetween),cy*(1.5+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(1.4+inbetween),cy*(1.4+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(1.3+inbetween),cy*(1.3+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(1.2+inbetween),cy*(1.2+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))
par(new=T)
plot(cx*(1.1+inbetween),cy*(1.1+inbetween),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200))

abline(h=0,col=rgb(1,0,0))
abline(v=0,col=rgb(1,0,0))

# 凡例を書き添える 。
legend("topright", legend=c("y=Cos(θ)+Sin(θ)i","x=y=0"), lty =c(1,1),col=c(rgb(0,1,0),rgb(1,0,0)))
}

even_scale00(0)
```

**アニメーション化**(<font color=blue>順方向、中割り二枚</font>)
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20201108/20201108230654.gif)

```R
#アニメーション
library("animation")
Time_Code=c(0,1/30,2/30,0,1/30,2/30,0,1/30,2/30,0,1/30,2/30)
saveGIF({
for (i in Time_Code){
　even_scale00(i)
}
}, interval = 0.1, movie.name = "even_scale00.gif")
```

**アニメーション化**(<font color=blue>逆方向、中割り二枚</font>)
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20201108/20201108231302.gif)

```R
#アニメーション
library("animation")
Time_Code=c(0,2/30,1/30,0,2/30,1/30,0,2/30,1/30,0,2/30,1/30)
saveGIF({
for (i in Time_Code){
　even_scale00(i)
}
}, interval = 0.1, movie.name = "even_scale01.gif")
```
**アニメーション化**(<font color=blue>どちらにも見える、中割り一枚</font>)
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20201108/20201108231924.gif)

```R
#アニメーション
library("animation")
Time_Code=c(0,1/20,0,1/20,0,1/20,0,1/20,0,1/20,0,1/20)
saveGIF({
for (i in Time_Code){
　even_scale00(i)
}
}, interval = 0.1, movie.name = "even_scale02.gif")
```
#対数尺(<font color=blue>Logarithmic Scale</font>)の場合
**原型**
![Rplot04.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/597772/c0414264-e980-f628-977d-664307dc1daf.png)

```R
c0<-seq(0,pi*2,length=61)
cx<-cos(c0)
cy<-sin(c0)
plot(cx*(1-exp(-1)),cy*(1-exp(-1)),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="Logarithmic Scale",xlab="Cos(θ)",ylab="Sin(θ)i",col=c(200,200,200,200))
par(new=T)
plot(cx*(1-exp(-2)),cy*(1-exp(-2)),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200,200))
par(new=T)
plot(cx*(1-exp(-3)),cy*(1-exp(-3)),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200,200))
par(new=T)
plot(cx*(1-exp(-4)),cy*(1-exp(-4)),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200,200))
par(new=T)
plot(cx*(1-exp(-5)),cy*(1-exp(-5)),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200,200))
par(new=T)
plot(cx*(1-exp(-6)),cy*(1-exp(-6)),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200,200))
par(new=T)
plot(cx*(1-exp(-7)),cy*(1-exp(-7)),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200,200))
par(new=T)
plot(cx*(1-exp(-8)),cy*(1-exp(-8)),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200,200))
par(new=T)
plot(cx*(1-exp(-9)),cy*(1-exp(-9)),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200,200))
par(new=T)
plot(cx,cy,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="", col=rgb(0,1,0))

abline(h=0,col=rgb(1,0,0))
abline(v=0,col=rgb(1,0,0))

# 凡例を書き添える 。
legend("topright", legend=c("y=Cos(θ)+Sin(θ)i","x=y=0"), lty =c(1,1),col=c(rgb(0,1,0),rgb(1,0,0)))
```
**関数化**(<font color=blue>見た目は同じ</font>)
![Rplot05.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/597772/afda59d3-cf01-92df-adf2-929d8a80dd26.png)

```R
logarithmic_scale00<-function(inbetween){
c0<-seq(0,pi*2,length=61)
cx<-cos(c0)
cy<-sin(c0)

c0<-rev(seq(-9,0,length=10))

for (i in c0){
plot(cx*(1-exp(i+inbetween)),cy*(1-exp(i+inbetween)),type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="",xlab="",ylab="",col=c(200,200,200,200))
par(new=T)
}

plot(cx,cy,type="l",xlim=c(-1,1),asp=1,ylim=c(-1,1),main="Logarithmic Scale",xlab="Cos(θ)",ylab="Sin(θ)i", col=rgb(0,1,0))

abline(h=0,col=rgb(1,0,0))
abline(v=0,col=rgb(1,0,0))

# 凡例を書き添える 。
legend("topright", legend=c("y=Cos(θ)+Sin(θ)i","x=y=0"), lty =c(1,1),col=c(rgb(0,1,0),rgb(1,0,0)))
}

logarithmic_scale00(0)
```
**アニメーション化**(<font color=blue>順方向、中割り二枚</font>)
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20201109/20201109001532.gif)

```R
#アニメーション
library("animation")
Time_Code=c(0,2/3,1/3,0,2/3,1/3,0,2/3,1/3,0,2/3,1/3)
saveGIF({
for (i in Time_Code){
　logarithmic_scale00(i)
}
}, interval = 0.1, movie.name = "logarithmic_scale01.gif")
```

**アニメーション化**(<font color=blue>逆方向、中割り二枚</font>)
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20201109/20201109000846.gif)

```R
#アニメーション
library("animation")
Time_Code=c(0,1/3,2/3,0,1/3,2/3,0,1/3,2/3,0,1/3,2/3)
saveGIF({
for (i in Time_Code){
　logarithmic_scale00(i)
}
}, interval = 0.1, movie.name = "logarithmic_scale00.gif")
```

**アニメーション化**(<font color=blue>どちらにも見える、中割り一枚</font>)
![image.gif](https://cdn-ak.f.st-hatena.com/images/fotolife/o/ochimusha01/20201109/20201109002400.gif)

```R
#アニメーション
library("animation")
Time_Code=c(0,1/2,0,1/2,0,1/2,0,1/2,0,1/2,0,1/2)
saveGIF({
for (i in Time_Code){
　logarithmic_scale00(i)
}
}, interval = 0.1, movie.name = "logarithmic_scale02.gif")
```
#「シュレーディンガーの猫」は実在した？
まぁ、とりあえずこうやって「**観測者**」にも生死が特定出来ない猫自体は簡単に生み出せてしまうという話です。そんな感じで、以下続報…