ラベル Thunkable の投稿を表示しています。 すべての投稿を表示
ラベル Thunkable の投稿を表示しています。 すべての投稿を表示

2023年8月10日木曜日

A Thunkable app reproducing the polarized filters experiments

I created an app in Thunkable that faithfully reproduces the photon polarization experiment. Thunkable is a no-code programming system, similar to MIT App Inventor, but it incorporates a unique concept and is mainly an application development environment for advanced users.

●Purpose of the app
The main aim of the app is to familiarize students with the fundamentals of quantum computing through photon polarization. What I am doing here is an experiment in which linear polarizers are superimposed and images are viewed. When two polarizing sheets are stacked vertically (axis angle 0°) as in Fig.1(a), it is clearly visible, but when the front sheet is tilted 90° as in Fig.1(b), it is not visible at all. However, if another polarizing sheet is inserted between these two sheets at an angle of 45° as in Fig.1(c), it can be seen to some extent. Since the polarizing sheet is a filter, it is hard to imagine that it is better to see three polarizers than two. No matter how many times I try, it still surprises me. 
●App overview
The newly developed Thunkable app, as shown in Fig. 2, faithfully reproduces this mysterious phenomenon on a smartphone screen.
Also, please take a look at the video below, which shows the operation in the order of (a), (b), and (c) in Fig.2. The installation of the polarizing sheet is specified using a switch, and the angle of its axis can be changed by operating a slider.


●Mathematical model behind the app
This phenomenon can be explained by the quantum computing model shown in Fig.3. That is, it can be explained using an ordered orthonormal basis that corresponds to the orientation of the polarizer. The details are explained in the section “The Basis Associated with a Given Polarization Direction” in Reference [1].

●Important points when creating the app
When developing this app, it is necessary to find the probability p that a photon polarized at an arbitrary angle θ passes through a polarizing sheet with a tilt angle α. It can be calculated using the formula shown in Fig.4.
By reflecting this probability of passing proportionally to the transparency of the colored paint, we were able to reproduce a close-to-realistic appearance on the smartphone screen.

(Note) In this app, calculations are made assuming that the square polarizer is large enough. Therefore, when a small polarizing plate is used as shown below, the appearance of the edge portion may differ from the actual experimental results.
●Link to the app
(This app has been tested on Android, but not yet on iOS.)

Reference
 [1] Chris Bernhardt: Quantum Computing for Everyone, The MIT Press, 2020.

2019年4月22日月曜日

A simple demo app using ThunkableX Cloud Variables

Of the few existing App Inventors, ThunkableX has its own distinctive features. Except for being able to create common source programs (blocks) for Android and iOS, I focused on the newly introduced cloud variables. These extend the scope of traditional variables to cloud space based on the Firebase (a kind of real-time database). Normally, the database is created with a user-specific id, but if you know its URL, you can access that cloud variable. When an authorized user updates the value of a variable, the event is immediately received by other apps. Such a facility enables efficient development of database applications, etc.

An example of initializing such cloud variables is shown in Figure 1. You can see that Firebase tags can be mapped to cloud variables. Hierarchical tags can also be cloud variables, such as “fireLoc/lat”.


After initializing these cloud variables, they can be referenced in several ways. Figure 2 shows five access blocks for the cloud variable Betty. Particularly, I would like to note a block called “when Cloud Betty is initialized or changed”. This block allows you to know in real-time the updates to cloud variables, and based on that you can easily set up your application logic.


Gram app [2] is a famous example of using cloud variables. This is a very fine app, but it's somewhat complicated for general programmers. So I created a simpler demo app. Figure 3 shows that. Jack wants to know the location of his daughter Betty in real-time. But, Betty allows sending her location only when she presses a button on her smartphone.


The complete block diagram of ThunkableX that achieves this is shown in Figure 4. Figure 4(a) is for the sender, Betty; and Figure 4(b) is for the receiver, Jack. This diagram shows that using cloud variables make programming much easier. You can access the contents of the database without using Firebase blocks such as registering listeners, storing values in the database, etc. In Fig. 4(a), the location information is fetched by GetCurrentLocation and stored in the cloud variable Betty. Also, in Figure 4(b), updates to the cloud variable Betty is automatically detected, so the result is immediately reflected in the map.


References
[1] thunkable cloud variables, https://docs.thunkable.com/variables
[2] the Gram app, https://x.thunkable.com/projectPage/5bbff7e035aa10fd7702f479

2019年1月30日水曜日

Java Rubik's Cube

On the Thunkable site, "Thunkable App of the Month - July 2018" had been announced. It is an application to explain the solution of Rubik's Cube. I have a special Rubik's cube called Java Rubik's Cube. It was distributed as a souvenir at Sun Tech Days 2007 in Tokyo more than 10 years ago. I completely forgot the solution, but this app should lead me well.


Rubik’s Cube Solving Guide by Winston Riggs

Java Rubik's Cube (on the left)

Java Rubik' Cube is somewhat more difficult than general Rubik's Cubes in the first stage. When a surface is filled with the same images, they must be arranged in the same direction as in the following figure. However, after overcoming this constraint, the latter half of the solution might become rather easy.


2018年8月18日土曜日

Mobile Apps Lecture in the Campus Visit attracts many high school students

At the campus visit to Kanagawa Institute of Technology (in Japan) that was held this summer (on August 18, 2018), Department of Information and Computer Sciences opened a lecture on application development for smartphones. Approximately 40 high school students participated and experienced application development using MIT App Inventor. Most of them use smartphones, but have little experience in computer programming. For such students as well, it is aimed to have experiences that using App Inventor can develop quite sophisticated applications.  With this as a trigger, we hope that many of them will head to the fields of computer science and computer engineering in the future.


The following three subjects were prepared:

Experience of image recognition by artificial intelligence

Shoot something interesting with a smartphone camera and send the image to Microsoft's Image Recognizer. Normally, in several seconds to several tens of seconds, the result of recognition of the image (what is shown, what kind of situation it is, etc.) is returned as a short English sentence. The student evaluates the recognition result (with max 100 points). Furthermore, comments such as which is good or bad are also given. By pressing a button, they can store and share the screen shot of the screen including the evaluation result into the Dropbox.


Your high school building emerges by scraping the screen

Given the student's high school name (or place name) and press the button, the corresponding building appears on the Google Maps. But as soon it disappears, the screen gets darker (filled with gray). But do not worry, rub your screen with your fingers as if rubbing with a coin. Then the school building will gradually appear again.


Reproduction of actual traveling locus at Suzuka Circuit

Our University Solar Car actually ran the Suzuka Circuit at the race. By using the trajectory data (latitude and longitude taken every 5 seconds) , the running is reproduced. The latitude and longitude are converted to the coordinates of the smartphone screen. Latitude, longitude, elapsed time, current speed (approximate), etc. are displayed every moment. It can be confirmed that it is fast in the straight part and slower near the hairpin. You can also display it faster or slower than the actual time.


On this day, starting from scratch, they first worked on simple exercises. The actual material used is the second one (Your high school building emerges by scraping the screen). However, because they have not enough time, they cannot accomplish this from scratch. So we prepared semi-finished products so that they could complete it by adding some processing (block) to it. Many students completed the targeted application. They are expected to go home with this and review it again. Furthermore, based on that, we hope that they will create a program to solve the problem they found themselves.


In this lecture, we targeted only Android. Many participants brought their own Android, but to the participants who did not, the organizer lent Android terminal. However, nearly one third of the participants have also found that they usually use iPhone. Currently, iOS version of MIT App Inventor is under development. In addition, Thunkable already released cross platform ThunkableX (iOS + Android). In the near future, we intend to prepare lectures for iOS version as well.

2018年8月14日火曜日

夏休みの宿題代行じゃありませんが

 生徒、学生の皆さんにとっては夏休みはまだ大分あります。夏休みの宿題は昔のように出されているのではないでしょうか。「宿題代行サービス」というのも存在するようです。この記事は、そんなことはしませんが、何かヒントになることがあればうれしいです。

 台風の進路軌跡を、自分自身でスマホに描いてみませんか?もちろん、すでに、台風進路図などは公開されていますが、自分で好きな台風アイコンも選んで(作って)進路に沿って実際に動かして見ると、何か新鮮みを感じ取れるのではないでしょうか。やってみなきゃ分からない!(NHK番組 "大科学実験"でもそう言っていた。)

  • 気象庁のホームページから、過去の台風の中心位置、中心気圧、最大風速、大きさ等々のデータを得られます。
  • そのうちから、超大型のまま御前崎に上陸した台風21号(2017年)を取り上げます。その中心位置と最大風速の変化を図示します。
  • 下図からわかるとおり、この台風は発生後まもなく「最大風速は猛烈な」となり、衰えずにそのまま御前崎に(最大風速80m/sで)上陸してしまいました。
  • 台風でたいへんな被害を受けた方々にはお見舞いを申し上げます。そのうえで、台風の進路を以下のように眺めているとその軌跡は美しい自然の神秘とさえ思えます。



 さて、このアプリは、Thunkable Classic (for Android) で作成しました。MIT App Inventorでもほとんど同じように作成できるはずです。そのブロック図は、以下のように単純なものです。中央の大き目のブロックでは、台風の位置に独自マーカーを打っています。これを観測時間間隔(3時間とか6時間)ごとに繰り返しています。最後部1/3くらいのブロックは、単に最大風速に応じた独自マーカーを設定するだけです。


 なお、上記の結果図には、台風進路を折れ線でも示していますが、上記プログラムにはそれがありません。独自のマーカー(最大風速により色を変えた)だけを表示しています。進路の折れ線も描くには、以下のブロックを(マーカー描画の次に)追加する必要があります。



■さらに発展形も考えられる
  • 今回は簡単にするため、制御ボタンなどを付けませんでした。表示スピードを変化させる、発生からの経過時間や中心気圧も表示する、等々できると思います。
  • たくさんの台風を登録して、適宜選択表示するには、ファイルを使ったり、あるいは、クラウドDBと接続するなども十分可能です。Thunkableにはそれらの機能も各種備わっていますので、使いこなすと素晴らしい独自のアプリになるでしょう。

2018年6月26日火曜日

共通のソースプログラムでiOS用とAndroid用のアプリを作れるThunkableX(その1)

*最後にある【ご参考事項】を補強しました。2018-6-28

これまでずっと利用してきたMIT App Inventor for AndroidとThunkableですが、限時点でThunkableの方に、大きな進展がありますので、それを試行してみます。注目点はいくつかあるのですが、共通のひとつのソースプログラム(デザインとブロック)を用いて、iOS上でもAndroid上でも実行できる!これが最大のポイントです。

さっそく、画像認識アプリを作ってみます。3つのパートの構成にしました。初級向けには、最初のPart A (または、Part A + Part B)だけでもよいかと思います。

  • Part A:スマホで認識させたいものを撮影する。それをMicrosoft Recognizerに送って、何が写っているかの認識結果(英文)を表示させる。
  • Part B:これと同じですが、撮影済みのPhoto Libraryにある画像も認識させる。
  • Part C:認識結果に、評点と感想(コメント)を付ける。それを後で仲間とシェアするために、Media DBとRealTime DB(Firebase)に格納する。

以下に、そのソースプログラム(デザイン部とブロック部)を示します。以下がその全てです。

画像認識アプリのデザイン部

画像認識アプリのブロック部

このソースプログラム全体は、以下に公開していますので、詳細はそちらをご覧ください。ご自分のgmailアカウントに入っている状態で、下記リンクをクリックすると、自動的に、ThunkableXのプロジェクトとして、上記のソースプログラムが設定されます。

https://x.thunkable.com/copy/3a30e4c6b8b976811b85aef29bfac2e8

このソースプログラムを、iPhone用とAndroid用にビルドして、それぞれ実行させた例を以下に示します。

共通ソースプログラムからビルドして実行した例
Part Cでは、各人が色々なものを撮影して、仲間同士でその結果を検討するために、認識結果とその人の評点、コメント(意見)を保存します。撮影画像の保存は、Media DBというものに格納します。その格納場所を示すURLとその他の情報を、RealTime DB(Firebase)に格納します。

撮影画像のMedia DBへの格納例
認識結果やユーザ評点などのRealTime DBへの格納例

【ご参考事項】
今回の試行で気がついたことなどを、ご参考までに記します。
  1. 上記に公開しているソースでは、Media DBとRealTIme DBを利用するためのAPIキー情報などは削除してあります。生徒らに、Part Cを使わせる場合には、管理者がこれらのAPIキーなどを取得して各人に設定させる必要があります。
  2. これら2つのDBの設定については、 下記をご覧ください。Thunkable Docs→「Thunkable Cross Platform X」→「Create」→「Components」→「Data」→RealTimeDB, Media DB
  3. 従来のAndroid用のThunkable(Thunkable Classic)と比べて、今回のThunkableXは、使えるセンサー類の少なさが目立ちます。またExtensions機能もありません。しかし、そうだとしても、iOSにも共通に使えるようになったメリットは非常に大きいです。不足の機能も順次追加されていくはずです。
  4. iOS用のビルドには、現時点では、10分〜15分程度かかります。したがって、一定の完成度になるまでは、Live Testを使う方がよいです。WiFi環境下で、PCとiOSを接続して、リアルタイムにプログラム修正、実行ができます。Live Testには、Apple Storeにある「Thunkable Live」が必要です(→下図参照)。
  5. iOSのビルド結果は、メールで通知されます。それをiOSで(PCではなく)受信して、示されたリンクをクリックするだけでインストールされます。しかしながら、現時点では、iOS側にダウンロードできるのは、1アプリに限定されています。別のアプリをダウンロードすると置き換わってしまいます。
  6. iOSにビルドしたファイルをインストールする際に「信頼されていないソフト...」が表示される場合があります。「設定」→「一般」→「プロファイルとデバイス管理」ヘ進み、「Rappidly Inc」を「信頼する」にして下さい。
  7. Android用にも、Live Testは使えますので重宝します。そのためには、Google Playストアにある「Thunkable Live」が必要です(→下図参照)。ビルドを行う場合、通常ほぼ直ちに結果が返ってきますが、PC側にダウンロードされるので、それをメールか、Dropboxなどを経由してAndroidにインストールする必要があるようです。
  8. 今回のThunkableXと、従来のThunkableおよびMIT App Inventorとのソースレベルの互換性はほぼ全面的に失われています。iOSとの共通化のためには、全面的に設計を見直す必要があったとのことです。その意気込みは高く評価したいと思います。
Live Testに必要なアプリ