Saat ini rumput masih menjadi makanan utama sapi perah namun keberadaan rumput yang subur dan disukai sapi mulai jarang ditemukan secara bebas sehingga kegiatan "ngarit" (jawa: mencari rumput) sudah banyak ditinggalkan bagi pemilik sapi.
Bagi pemilik sapi perah, sekarang lebih mudah membeli rumput gajah daripada mencari rumput di sawah atau hutan yang keberadaannya semakin jarang. Menanam rumput gajah sendiri juga bukan sebuah pilihan yang menarik karena harus merawatnya dengan memupuk dan mengairi; sebuah hal yang sulit sekarang di mana pupuk relatif mahal dan musim kemarau yang berkepanjangan dengan datangnya hujan yang sulit diprediksi.
Di sisi lain, kotoran sapi selama ini telah menjadi pupuk kandang dan dipakai di berbagai daerah. Pertanyaannya kenapa tidak menanam rumput gajah dengan pupuk kotoran sapi saja? Jawabannya biasanya adalah kotoran sapi tersebut dijual sehingga tidak memungkinkan (tidak boleh) untuk digunakan sebagai pupuk kandang. Selain itu, agar kotoran sapi dapat menjadi pupuk, kotoran sapi harus dibiarkan dulu (fermentasi) beberapa minggu. Penggunaan langsung kotoran sapi pada tanaman berakibat tidak baik. Hal lain dari penggunaan kotoran sapi sebagai pupuk adalah, tanaman masih membutuhkan air sehingga sulit dilakukan saat musim kemarau.
Saat ini air kencing sapi menjadi limbah yang terbuang percuma karena tidak dapat dijual dan bermasalah bagi lingkungan karena menimbulkan polusi bau karena tempat pembuangannya biasanya dijadikan satu dengan kotoran sapi; kotoran sapi tidak lekas kering dan kotoran sapi yang basah baunya sangat menyengat. Padahal jika ditelaah, air kencing sapi memiliki kandungan urea yang cukup tinggi sehingga bagus untuk tanaman, terutama untuk pertumbuhan rumput gajah.
Penggunaan air kencing sapi sebagai pupuk untuk rumput gajah (makanan utama sapi) memiliki beberapa keuntungan. Pertama adalah bebas biaya karena merupakan limbah dari sapi itu sendiri.
Keuntungan kedua adalah menyelesaikan masalah bau dari pembuangan air kencing sapi. Selama ini air kencing sapi dibuang ke tempat yang sama dengan kotoran sapi sehingga kotoran sapi tidak lekas kering. Hal ini menimbulkan bau yang menyengat dan kotoran sapi yang masih basah tidak dapat dijadikan pupuk kandang. Dengan mengalirkan air kencing sapi ke lahan penanaman rumput gajah maka secara otomatis kotoran sapi tidak tercampur dengan urine sapi dan lebih cepat kering (lebih cepat terfermentasi menjadi pupuk kandang dan dapat dijual).
Keuntungan yang ketiga adalah meyelesaikan masalah ketiadaan air saat kemarau. Dengan menggunakan air kencing sapi, selain sebagai pupuk dengan kandungan urea yang tinggi, air kencing sapi juga berfungsi untuk mengairi rumput gajah sehingga tidak mengalami kekeringan.
Sunday, October 20, 2013
Monday, October 14, 2013
Ini Takbir Keliling atau mp3 Player Keliling
Bawa truk, sound system menggelegar, diiringi puluhan motor bersuara keras dan digeber-geber gasnya.
Tapi takbirnya dari mp3 player, hampir tak ada peserta konvoi (ups, takbir keliling :) ) yang bertakbir. Tak adakah pikiran bahwa Tuhan mungkin sampai bosan mendengar mp3 takbir yang itu-itu saja?
Bagi pengejar pahala? Apakah tidak terpikirkan bahwa yang mendapat pahala adalah yang suaranya terekam di mp3 takbir itu?
Bagi yang takbir keliling dengan motor. Adakah terlintas di pikiran bahwa berkendara di lalulintas padat bahkan sampai memakai lajur kanan meningkatkan peluang kecelakaan dan tidak memakai helm dapat meningkatkan peluang gegar otak?
Tapi meninggal saat takbir kan masuk surga, iya kan!
Benarkah?
Eh, anu, maksudku benarkah saat itu anda membaca bacaan takbir dan bukan sibuk memutar-mutar gas motor dan membunyikan klakson?
Thursday, October 3, 2013
Tutup Radiator dan Reservoir
Barang kecil dan murah namun jika rusak dan tidak segera diganti akan jadi mahal, karena harus ganti radiator atau malah ganti mesin.
Hal yang terjadi jika tutup radiator rusak:
-radiator tidak dapat mempertahankan tekanan di dalam radiator; seharusnya lebih tinggi dari udara luar. Tekanan yang lebih tinggi menyebabkan titik didih coolant/air radiator juga tinggi sehingga pertukaran panas lebih efektif. Kalo fungsi ini gagal, air radiator akan mendidih di suhu 100 atau di bawahnya; pertukaran panas tidak efektif.
Karena mendidih (dan tentu saja menguap), maka air radiator akan cepat habis
Hal lain yang terjadi jika tutup radiator rusak, air radiator akan keluar menuju reservoir saat panas (hal yang normal, karena air volumenya bertambah saat panas) namun tidak mau kembali ke radiator saat dingin karena tidak diijinkan oleh klep di tutup radiator; air radiator akan berkurang (dan air di reservoir akan bertambah banyak bahkan sampai tumpah). Normalnya air di reservoir akan kembali ke radiator setelah mesin dingin, sehingga volume air di dalam radiator tetap.
Hal lain yang kadang lolos dari perhatian adalah selang di tutup reservoir yang masuk ke dalam reservoir. Jika selang ini longgar, maka udara akan ikut masuk saat radiator menyedot air kembali ke radiator sehingga jika dicek, air radiator akan berkurang meskipun air di reservoir masih ada (bahkan sampai tumpah)
Friday, August 30, 2013
Tombo Ati (Carnaval Version)
Tamba ati iku lima sak wernane ... (backing vocal: GOYANG THITHIK JOSS...)
Maca Al Qur'an angen-angen sak maknane
Kaping pindho shalat wengi lakonana (backing vocals: BUKAK SITHIK JOSS )
.....
Kayaknya lagu-lagu sekarang lebih mementingkan irama daripada isi. Lirik boleh apapun asal irama easy listening (atau 'itu-itu saja').
Pernah juga dengar lagu religi koplo satu album iramanya ya satu pola itu tok, beda lirik. Semakin aneh lagi karena disetel di masjid yang kosong tidak ada kegiatan; semata-mata agar terlihat religius (religius koplo?).
Maca Al Qur'an angen-angen sak maknane
Kaping pindho shalat wengi lakonana (backing vocals: BUKAK SITHIK JOSS )
.....
Kayaknya lagu-lagu sekarang lebih mementingkan irama daripada isi. Lirik boleh apapun asal irama easy listening (atau 'itu-itu saja').
Pernah juga dengar lagu religi koplo satu album iramanya ya satu pola itu tok, beda lirik. Semakin aneh lagi karena disetel di masjid yang kosong tidak ada kegiatan; semata-mata agar terlihat religius (religius koplo?).
Thursday, August 29, 2013
Sunday, August 25, 2013
Front Row Replacement on Mountain Lion
I realized that OS X Mountain Lion didn't have Front Row anymore; in fact, it deprecated since release of Lion.
I just got RowMote Pro on my iPhone and want to test it on Front Row and... nothing happenned.
I searched and there is a way to install back Front Row on Lion and (more complicated) on Mountain Lion, but most they suggest to use XBMC instead.
I installed it from XBMC site and Rowmote detect it instatantly and so does XBMC; it can be controlled through rowmote. I don't know what happened but the XBMC icon just appear on my iPhone Rowmote apps.
As bonus, we can install official XBMC apps for iOS to from iTunes
I just got RowMote Pro on my iPhone and want to test it on Front Row and... nothing happenned.
I searched and there is a way to install back Front Row on Lion and (more complicated) on Mountain Lion, but most they suggest to use XBMC instead.
I installed it from XBMC site and Rowmote detect it instatantly and so does XBMC; it can be controlled through rowmote. I don't know what happened but the XBMC icon just appear on my iPhone Rowmote apps.
As bonus, we can install official XBMC apps for iOS to from iTunes
Saturday, August 24, 2013
Timer For Sleepy Eyes on Retractor Headlight
Here's the application of previous post on PCB dot matrix. I don't applied it to my Mazda 323F Astina Popup yet.
Friday, August 23, 2013
Timer for Sleepy Eyes
Here my search result of IC 555 application that very close to what I want; the Pivot Headlight Retractor like Sleepy Eyes on my Mazda 323F Astina
the 555 timer is set to turn on the buzzer when the push switch is pressed; the buzzer sounds for approximately 8 seconds. This is a monostable circuit as it works only once. The switch must be pressed again for the buzzer to sound again.
Well, almost there, but I do need more...
It have to- turn on when the headlight goes off after on
- turn off after certain seconds (more or less half second)
- reset timer when headlight goes on
The schematic above didn't meet the requirement as the push button act as trigger while my 'trigger' is the headlight off condition. So if it applied directly, the timer will run continuosly since the trigger is always on and the 'reset' is above 0.7 V.
So, here is my mod
oops, what's wrong? oh, it's like pin 4 must go to Batt, not headlight, :)
Thursday, August 22, 2013
IC 555
Setelah muter-muter cari diagram persamaan untuk Pivot Retractor Headlight untuk bikin Sleepy Eyes di Astina tanpa hasil, akhirnya berkesimpulan, kenapa tidak buat timer sendiri saja?
Browsing dan ...
Tentu saja yang muncul paling atas adalah IC klasik 555 yang tersohor itu. Sempat bingung karena lama tidak otak-atik perangkat elektronika, tapi sleepy eyes harus berhasil, :). Karena itu saya menyempatkan diri buka datasheet IC 555 dan mempelajari karakteristik IC timer ini.
Dari diagram terlihat bahwa GND jelas ke ground dan Vcc ke power supply DC, Vcc bisa bernilai 3V hingga 15 V.
OUT merupakan output dari IC ini dengan nilai sekitar 1.7 V dibawah Vcc atau GND
OUT menjadi tinggi (high; ada output; output terjadi) jika TRIG memiliki tegangan dibawah 1/2 tegangan CTRL yang biasanya bernilai 1/3 Vcc. Saat OUT aktif dan mengalirkan arus, maka timer akan mulai berjalan.
Timer dapat direset dengan menyambungkan RESET ke GND, namun timer tidak dapat aktif kembali jika RESET memiliki tegangan dibawah 0.7 V.
Timer berhenti (OUT berhenti mengalirkan arus) saat THR lebih besar dari CTRL.
DIS berfungsi untuk mengosongkan kapasitor.
Tuesday, August 20, 2013
CMS dan Keamanan Website
Saat ini sedang populer penggunaan CMS pada berbagai laman web. Kita sudah tidak begitu asing dengan blogger, wordpress, moodle dan joomla.
CMS (Content Management System) adalah sebuah sistem komputer yang dapat mempublikasi, menyunting, memodifikasi konten, melakukan pengaturan dan pemeliharaan sebuah halaman web dari sebuah halaman saja tanpa perlu pengetahuan bahasa pemrograman web.
CMS menyediakan sekumpulan menu untuk menambah halaman web, mengubah background, membuat menu/link di sidebar dan berbagai fitur web lainnya.
CMS menawarkan berbagai kemudahan. Seorang blogger hanya perlu fokus pada tulisan yang dia buat tanpa disibukkan oleh kode-kode CSS atau HTML. Pengajar online hanya perlu menyediakan dan mengupload bahan ajar beserta ujiannya tanpa perlu pusing-pusing mengembangkan sistem anti contek karena CMS Moodle dapat mengacak urutan soal dan urutan jawaban beserta timernya.
Ada berbagai macam jenis CMS berdasarkan fungsinya: blog, forum, e-learning, portal bahkan toko online.
CMS dengan berbagai kemudahannya telah membuat aktivitas publishing di dunia maya menjadi lebih mudah dan menyenangkan. Meski demikian ada hal-hal yang perlu diwaspadai saat kita memutuskan untuk menggunakan CMS untuk halaman web kita yaitu keamanan.
Karena CMS gratis tersedia secara bebas, sebuah CMS dapat dipelajari kode sumbernya dan pihak tertentu mungkin menemukan celah keamanan yang dapat digunakan untuk men-deface sebuah alamat web yang menggunakan CMS tersebut.
Update terbaru sebuah CMS mungkin dapat menambal sebuah celah keamanan namun karena sifat free dari CMS tersebut, maka setiap orang dapat beramai-ramai mendownloadnya dan beberapa pihak mungkin memfokuskan diri untuk mencari celah keamanan lain.
Subdomain um.ac.id pernah di-deface dengan memanfaatkan exploit dari sebuah free-CMS. Apakah ini berarti jaringan internet UM tidak aman? Jawabnya adalah: hal tersebut tidak ada hubungannya dengan jaringan.
Jika jaringan diibaratkan jalan dan pintu sebuah rumah. Maka halaman web dapat diibaratkan sebagai penghuni rumah yang membawa tas berisi uang. Sebuah CMS yang memiliki celah keamanan ibarat tas yang berlubang atau sobek. Seseorang hacker bisa saja mengganti uang di dalamnya dengan daun (mengubah konten web) atau mengambil semua uang hingga tasnya kosong ( menghapus isi web). Sebuah free CMS adalah sebuah tas yang desainnya (dan tempat sobeknya) diketahui oleh umum.
Kenapa tidak ditutup saja pintu rumahnya agar aman? Tentu saja bisa, namun dengan demikian maka pengunjung tidak dapat masuk ke dalam rumah (halaman web tidak dapat diakses).
Bagaimana agar aman? Tentu saja kita harus menutup celah keamanan dengan cara kita sendiri. Cara lainnya adalah dengan menggunakan CMS premium yang tidak tersedia secara bebas atau mengembangkan CMS sendiri sehingga kode sumber tidak dapat dipelajari oleh umum.
Karena itu, sedang ditelaah sebuah peraturan untuk keamanan website yang berada dibawah domain UM; pada tahun 2013 halaman web yang berada di domain um.ac.id wajib mengembangkan interface halaman web sendiri atau menggunakan CMS premium.
Nugroho Adi
(Pernah di post oleh penulis di http://berkarya.um.ac.id)
Saturday, August 17, 2013
Relay Single Pole Double Throw
'Mas, ada relay'
'Ada'
(Ambil box berisi macam-macam relay, disodorkan satu)
'Yang lima kaki'
...
'Yang ada 'a'nya atau tidak'
[yes, lega]
'Iya iya, yang ada 'a'nya'
'OK, berarti sampeyan mengerti'
(Ambil box satunya sambil senyum ceria)
'Memang kenapa mas?'
'Biasanya kalo jawabnya 'terserah' atau gak bawa contoh, saya gak menjual yang lima kaki, takutnya salah'
'...'
'harganya 30rb mas karena ada 'a'nya, kalo yang tidak ada cuma 25rb'
'Beli DUA mas'
...
Demikian sekilas percakapan di sebuah toko part mobil setelah muter-muter di toko lain tidak menemukan relay yang dimaksud. Relay yang akan saya gunakan untuk menata ulang pengkabelan untuk motor retractor popup 323F astina saya.
Ada apa dengan huruf 'a'? Kenapa bisa lebih mahal padahal sama-sama lima kaki?
Relay yang saya cari adalah relay Single Pole Double Throw dengan lima kaki.
85 arus kecil
86 ground
30 sumber arus
87 tersambung ke 30 jika ada arus dari 85 ke 86
87a tersambung ke 30 jika TIDAK ADA arus dari 85 ke 86 (kaki 87a ini biasanya terletak di tengah)
Relay lima kaki yang biasa memiliki dua kaki 87 (
Thursday, August 15, 2013
Wednesday, August 14, 2013
Retractor Headlight on My Mazda 323F Astina
My Mazda 323F popup headlight suddenly refuse to retract. While the servicemanual book provide everything about it, I couldn't place the 'retractor unit' in my Astina. So I guest it's some kind of relay and decided to rewiring it.
My new retractor wiring depends exclusively on headlamp, either normal or beam. When the lights on, the retractor will 'up', and retract 'down' when lights are off.
Several diode present to prevent a mixed current and 'fireback' such as normal and beam headlight on in the same time or the relay active while the ignition is switched off.
(MX 5 / miata or RX 7 may have different cable colour)
(here the update using single SPDT relay)
(MX 5 / miata or RX 7 may have different cable colour)
(here the update using single SPDT relay)
Tuesday, August 13, 2013
Percy Jackson and the Singer of Apollo
It's part of Other Worlds, a compilation book by Rick Riordan, Shaun Tan, Ray Bradbury, Neal Shusterman and ...
However, being a fan of Percy Jackson series, Heroes of Olympus series and Kane Chronicles, I wish I could get just the Rick's tale since this is the only story I want to read in this one, :)
However, being a fan of Percy Jackson series, Heroes of Olympus series and Kane Chronicles, I wish I could get just the Rick's tale since this is the only story I want to read in this one, :)
Monday, August 12, 2013
Merpatiku buat sarang lagi horee...
Tanda mau bertelur, :)
Semoga anaknya gak dimakan kucing tetangga lagi (resiko memiliki tetangga yang punya berpuluh kucing)
Friday, August 9, 2013
Fisika FluidDynamic Masjid
Walaupun beberapa masjid sudah mulai ber-AC, meski tampan aneh dengan tiadanya air-blocker di pintu masuk sehingga udara dingin jadi lolos keluar, sebagian besar masjid 'besar' masih menggunakan kipas angin sebagai fitur plus-nya.
Secara konstruksi bangunan tidak masalah, dengan lubang udara di bawah kubah yang dimaksudkan agar udara panas bisa keluar.
Namun secara praktek ada yang aneh, aliran udara kipas mengarah ke bawah! Akibatnya udara panas dari jemaah (tiap orang rata-rata setara dengan lampu 100watt) yang seharusnya naik dan keluar lewat lubang udara dipaksa kembali ke bawah oleh kipas, efeknya udara panas malah masuk dari atas dan ruang jadi tambah panas, efek lainnya adalah jemaah jadi masuk angin terkena hembusan kipas, setidaknya saya.
Seharusnya aliran udara kipas mengarah ke atas agar udara panas yang secara alami bergerak ke atas bisa keluar lewat lubang udara bawah kubah, udara relatif segar masuk dari pintu dan jendela, dan jemaah tidak masuk angin terkena hempasan udara kipas.
Wednesday, August 7, 2013
Soliloquy
hei
Namaku ...tapi biasa dipanggil Gepeng trus merambat jadi Peng kadang Cipeng juga Meng, nDul
Sekolah, kabur, lebih enak di jalan
Gitar, nyanyi, gak penting lagu apa
pake ecek-ecek, kadang gak perlu repot nyanyi
kalo 'rajin' bisa dapat lumayan
LSM yang ngurusi anak jalanan, ngajak kembali sekolah.
Bagiku yang pernah sekolah, jalanan lebih menarik.
Matematika? Aku tahu hutang yang harus kubayar di warung mbok Yem pas ngecer rokok pagi-pagi sebelum 'dinas' di perempatan.
Geografi? Sudah pernah kemana-mana numpang truk atau pick-up bak terbuka kalo pas ke stadion atau lihat konser underground atau sekedar pengin naik, terserah mau diturunkan di mana.
Kimia? Aku tahu campuran yang bagus untuk oplosan yang bikin cepat 'tinggi' ataupun oplosan yang pas buat rame-rame.
Mungkin mereka lebih cocok mengajak si Panjul tetanggaku yang gak pernah sekolah.
Hasil sejam bisa buat nge-game online di warnet pojok perempatan. penjaga warnet ok saja, malah senang dapet uang receh buat kembalian pelanggan.
tindik
mabuk gratis
nge-lem
rambut
sepatu
preman kemanusiaan, menodong sisi kemanusiaan
di bawah koordinasi
slot tempat mangkal. kalo untung bisa dijual lagi dengan harga tinggi. Cari tempat yang kira-kira nanti jadi ramai.
Tuesday, July 16, 2013
XFCE Display Manager with Opera on FreeBSD
Thursday, July 4, 2013
FreeBSD on VBox with OS X Host
I use boot-only-iso 64 bit and the problem instantly arise because of my impatience.
Yup, I use 32 bit architecture on OS version setting (the first prompt in virtual box when we create new virtual machine). So change to 64-bit solved the problem, in some case, delete the vm and create whole new vm guarantee it.
Nothing special on the installation so, here is it:
Yup, I use 32 bit architecture on OS version setting (the first prompt in virtual box when we create new virtual machine). So change to 64-bit solved the problem, in some case, delete the vm and create whole new vm guarantee it.
Nothing special on the installation so, here is it:
Friday, May 3, 2013
Stuck on DFU or Recovery Mode or Connect to Itunes Logo Loop on iPhone
In the recent months, we've seen reports here and there of iPhones getting stuck in a restart loop. The black screen with the Apple logo shows up, holds for a while, and then disappears again; repeat ad infinitum. While it's not clear yet exactly what's triggering the issue (the complainants suspect that it may be a recent application update to blame), there is a tried and true way to get your iPhone, iPod touch, iPad or older iPod back to square one: either use recovery mode or do a DFU restore.
DFU (Device Firmware Update) mode is a means to getting your iPhone to interface with iTunes without iTunes automatically loading the latest version of iOS onto it (it skips the iBoot bootloader, for jailbreak aficionados). Differing from recovery mode -- where iTunes restores your iPhone to its original factory settings but with the latest iOS and firmware -- DFU mode allows you to change and choose the firmware you want to install onto your iPhone. For instance, you would use DFU mode if you want to install a previous version of iOS, jailbreak your iPhone or unlock your SIM. If (for whatever reason) standard recovery isn't working for you to get your device back to working condition, DFU may help you out.
Remember, if you restore your phone in any fashion (via the iTunes 'Restore' button, recovery mode or DFU) you will lose any modifications made to unsynced content or in-app data since your last iTunes sync (game states, voice memos, notes etc.). Be cautious.
So, here's the basic info on how to enter DFU mode (and it works for your iPod touch, too). Instructions may vary slightly by year or model.
- Connect your iPhone to your computer via USB and launch iTunes.
- Now turn your iPhone off. Hold down the sleep / power button at the top right of your iPhone, then slide your finger across the "slide to power off" button on your iPhone's screen. (If it won't turn off, press Home and Sleep/Power until the screen goes dark, then release.)
- Once your iPhone is off, hold down both the sleep / power button as well as the home button for 10 seconds. Once 10 seconds has elapsed, release the sleep / power button on your iPhone, but continue to hold the home button until the the above message has appeared in iTunes telling you that your iPhone has been detected in recovery mode. (If you just want to go to recovery mode, skip the 10- second hold on both buttons and simply connect the phone while holding down Home, then wait for 'Connect to iTunes' screen on the phone.)
If you see the Apple logo or the "connect to iTunes" screen on your iPhone, you're not in DFU mode. DFU leaves the screen of the iPhone completely black.
To exit DFU mode, simply hold down the sleep / power button and the home button together until your iPhone disappears from the device list in iTunes, then turn on the iPhone as normal.
Again, for most purposes (save jailbreaking) there's no practical difference between DFU and a regular restore, except and unless you're in a situation where your phone won't go into restore mode normally.
Now, what if iPhone stuck on restore loop instead of restart loop? It often happen if we upgrade the iOS. I've tried to exit it using "just" DFU mode with no result. Apparently it needs more step, ... and it is...
While in DFU mode
While in DFU mode
- while you plugged your iPhone and opening the itunes go to windows/system32/drivers/etc and open "hosts" file as administrator with notepad (Mac user: use Shift+Command+G and type /etc than open hosts file using TextEdit)
- remove the last to lines with word apple in it (or add # at the begining of line)
- safe the change
- go to itunes shift+ restore choose the custom ipsw (Mac user: alt+ restore)
- enjoy the restore with out any errors no 3014 or 1600 or any other error
Maybe, on Mac, we couldn't safe the change of hosts file or even worse, couldn't open it. In this case,
open Terminal Apps
type
sudo cp /etc/hosts ./Desktop (enter your password)
sudo chmod 777 ./Desktop/hosts
edit hosts file in Desktop using TextEdit and safe it, back to Terminal
sudo rm /etc/hosts /etc/hostsOld
sudo cp ./Desktop/hosts /etc/hosts
Thursday, May 2, 2013
Monte Carlo PI
c calculating pi by throwing stones
c
PROGRAM stones
IMPLICIT none
c
c declarations
REAL*8 area, x, y, DRAND48
INTEGER i, max, pi, seed
c
c set parameters (number of stones, seed for generator)
max = 1000
seed = 11168
c
c open file, set initial value, seed generator
OPEN(6, FILE='pif.dat')
pi=0
call seed48(seed)
c
c execute
DO 10 i=1, max
x = DRAND48()*2-1
y = DRAND48()*2-1
IF ((x*x + y*y) .LT. 1) THEN
pi = pi+1
ENDIF
area = 4.0 * pi/REAL(i)
WRITE(6,*) i, area
10 CONTINUE
STOP
END
PI on MPI
still trying...
program main
include "mpif.h"
double precision PI25DT
parameter (PI25DT = 3.141592653589793238462643d0)
double precision mypi, pi, h, sum, x, f, a
integer n, myid, numprocs, i, ierr
c function to integrate
f(a) = 4.d0 / (1.d0 + a*a)
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, numprocs, ierr)
10 if ( myid .eq. 0 ) then
print *, 'Enter the number of intervals: (0 quits) '
read(*,*) n
endif
c broadcast n
call MPI_BCAST(n,1,MPI_INTEGER,0,MPI_COMM_WORLD,ierr)
c check for quit signal
if ( n .le. 0 ) goto 30
c calculate the interval size
h = 1.0d0/n
sum = 0.0d0
do 20 i = myid+1, n, numprocs
x = h * (dble(i) - 0.5d0)
sum = sum + f(x)
20 continue
mypi = h * sum
c collect all the partial sums
call MPI_REDUCE(mypi,pi,1,MPI_DOUBLE_PRECISION,MPI_SUM,0,
& MPI_COMM_WORLD,ierr)
c node 0 prints the answer.
if (myid .eq. 0) then
print *, 'pi is ', pi, ' Error is', abs(pi - PI25DT)
endif
goto 10
30 call MPI_FINALIZE(ierr)
stop
end
Wednesday, April 24, 2013
Mencari Pi
Nilai Pi
Mencoba tanpa webworker. Pi dapat dihitung dengan kode berikut
var Pi=0, n=1, c=100000;
for (var i=0;i<=c;i++) {
Pi=Pi+(4/n)-(4/(n+2));
n=n+4;
}
perintah dalam tag <script> adalah sebagai berikut
function HitungPi()
{
var loop = document.getElementById("loop");
var c = parseInt(loop.value);
var f = parseFloat(loop.value);
var Pi=0, n=1;
try {
if (isNaN(c) || f != c ) {
throw("errInvalidNumber");
} else if (c<=0) {
throw("errNegativeNumber");
}
for (var i=0;i<=c;i++) {
Pi=Pi+(4/n)-(4/(n+2));
n=n+4;
}
document.getElementById("PiValue").innerHTML = Pi;
} catch (e) {
var msg = "Input Error: ";
if (e=="errInvalidNumber")
msg += "harus angka.";
else if (e=="errNegativeNumber")
msg += "Input harus positif.";
else
msg += e.message;
alert(msg);
}
}
.
Perintah dalam <body>
<label for="loop">Jumlah iterasi:</label>
<input id="loop" type="number" value="100" />
<input type="button" onclick="HitungPi()" value="Hitung Pi" />
<div id="PiValue">Nilai Pi</div>
Hello Canvas World
Back to first again
Tulisan di atas ditulis dalam canvas seperti kode di bawah. Di sini perintahnya adalah
context.fillText('Hello Canvas World',canvas.width/2-150,canvas.height/2+15);
context adalah '2d' dari canvas, dalam hal ini context kotak yang menyimpan perintah-perintah '2d' canvas seperti contoh diatas, yaitu menulis text.
fillText('tulisan', posisi_x,posisi_y) adalah perintah untuk menampilkan tulisan dengan warna sesuai fillStyle, yaitu 'green'
strokeText('tulisan', posisi_x,posisi_y) adalah perintah untuk menampilkan tulisan dengan warna 'tepi' sesuai strokeStyle yaitu 'red'
var canvas = document.getElementById('canvasexample'),
context = canvas.getContext('2d');
context.font = '38pt Arial';
context.fillStyle = 'green';
context.strokeStyle = 'red';
context.fillText('Hello Canvas',canvas.width/2-150,canvas.height/2+15);
context.strokeText('Hello Canvas',canvas.width/2-150,canvas.height/2+15);
Sunday, April 7, 2013
My Blackberry Experience (part3)
In term of ease of use, I prefer non qwerty phone, thus, I prefer other devices than blackberries (but z10, maybe)
Why I don't like qwerty phone, because I didn't use to it. My first smartphone has candybar form factor, w960i, and I barely use it keyboard because I prefer its handwriting method using stylus.
I still like it and hope iPhone include this feature (unfortunatelly Apple don't bother to include it). I think it's possible cause google applied it in its search engine (work on i Phone too)
I start to used dvorak on my macbook pro in 2009, and since then I "abuse" my home PC, my HP tx2100us, and two server at work keyboards to became dvorak layout. It's simpler and more balance (right and left stroke). Of course blackberry, with its infamous qwerty keyboard, slow me down a bit.
Unfortunately, it applies to iPhone too. Although it allows for changing layout, it don't provide dvorak. Nevertheless, I still prefer iPhone over blackberry because its ability to change its keyboard layout. I'm currently use azerty layout on iPhone.
http://aravir-rose.blogspot.com
Why I don't like qwerty phone, because I didn't use to it. My first smartphone has candybar form factor, w960i, and I barely use it keyboard because I prefer its handwriting method using stylus.
I still like it and hope iPhone include this feature (unfortunatelly Apple don't bother to include it). I think it's possible cause google applied it in its search engine (work on i Phone too)
I start to used dvorak on my macbook pro in 2009, and since then I "abuse" my home PC, my HP tx2100us, and two server at work keyboards to became dvorak layout. It's simpler and more balance (right and left stroke). Of course blackberry, with its infamous qwerty keyboard, slow me down a bit.
Unfortunately, it applies to iPhone too. Although it allows for changing layout, it don't provide dvorak. Nevertheless, I still prefer iPhone over blackberry because its ability to change its keyboard layout. I'm currently use azerty layout on iPhone.
http://aravir-rose.blogspot.com
My Blackberry Experience (part 2)
So, how about the Blackberry killer app, Blackberry Messenger?
I personally don't know what's so great about it and what's really different with others messenger apps.
My sister in law tell me that BBM benefit is ability to block people and prevent his/her to contact us. Because BBM connect people through PIN, blocked people won't be able to contact via phone number if didn't know our number or we change our number.
I though of that and feel that it's ridiculous. We know yahoo messenger, google talk, whatsapp and other messenger have blocking feature as well.
Another problem is PIN itself. It's tied to one device. While it comes handy as we don't need to create new account as we have new number, it ties us to just one device. If we get another blackberry device, we have to reinvite our contacts again (or just export it? IDK).
Sure whatsapp or LINE is very vulnerable, anyone had our number is able to contact us but what's so bad about it? They still able to text or call us, don't they? And it have (along yahoo, gtalk and other) great portability; we're free to change device and still use same account, even use it in desktop computer.
Maybe it's just me but I don't want to be tied with one device. (Don't you want to upgrade your blackberry device?)
Blackberry Messenger is still great app though, with million users of course, every blackberry owner use it. But in the end, I still found whatsapp or other traditional instant messenger come handy in term of portability.
http://aravir-rose.blogspot.com
I personally don't know what's so great about it and what's really different with others messenger apps.
My sister in law tell me that BBM benefit is ability to block people and prevent his/her to contact us. Because BBM connect people through PIN, blocked people won't be able to contact via phone number if didn't know our number or we change our number.
I though of that and feel that it's ridiculous. We know yahoo messenger, google talk, whatsapp and other messenger have blocking feature as well.
Another problem is PIN itself. It's tied to one device. While it comes handy as we don't need to create new account as we have new number, it ties us to just one device. If we get another blackberry device, we have to reinvite our contacts again (or just export it? IDK).
Sure whatsapp or LINE is very vulnerable, anyone had our number is able to contact us but what's so bad about it? They still able to text or call us, don't they? And it have (along yahoo, gtalk and other) great portability; we're free to change device and still use same account, even use it in desktop computer.
Maybe it's just me but I don't want to be tied with one device. (Don't you want to upgrade your blackberry device?)
Blackberry Messenger is still great app though, with million users of course, every blackberry owner use it. But in the end, I still found whatsapp or other traditional instant messenger come handy in term of portability.
http://aravir-rose.blogspot.com
Saturday, April 6, 2013
My Blackberry Experience (part 1)
After trying my sister-in-law's blackberry, I feel the urge to compare it with my 4S. This is the first post about it
Maybe it's not fair to compare that two device, iPhone is touch based device while blackberry is scroll-point-click based device, but I'm curious about why blackberry is so famous and became de-facto in business (at least in the past). Well, here is it...
My reaction the first time I grab the blackberry is, confused.
Maybe I used to touch my iPhone to make it work but the blackberry OS confuse me about almost anything. I don't even know how to unlock its display at first because "mute" button is "play" button, :).
The home screen displays few apps and when I want to open apps that not in home screen I have to scroll it down but wait,... it don't scroll. Apparently I have to click "all" first and then scroll it down. While it may easy but the problem is I have to highlight "all" first to click it. iPhone have fewer step to go to anything.
The first app I want to open is mail, it's app that make blackberry powerfull among businessman anyway and guess what? It is...
The push feature is great, it delivers email as "send" is clicked, and receives email as soon as the email sent by sender (whoever it is) thank to BIS.
Yeah, blackberry mail is ok but I found facebook for bb is terrible (second apps I opened after mail). Try to read a twenty lines comment and you know what I mean, you read several lines and when you scroll to read next lines, it goes to last lines, and few lines before last line, there is no way to read 'middle' line
....
Sure iPhone can't transfer file via bluetooth, or download music (or anything) outside app store, but it worth it, faster, smoother and I'll stick with it.
http://aravir-rose.blogspot.com
Maybe it's not fair to compare that two device, iPhone is touch based device while blackberry is scroll-point-click based device, but I'm curious about why blackberry is so famous and became de-facto in business (at least in the past). Well, here is it...
My reaction the first time I grab the blackberry is, confused.
Maybe I used to touch my iPhone to make it work but the blackberry OS confuse me about almost anything. I don't even know how to unlock its display at first because "mute" button is "play" button, :).
The home screen displays few apps and when I want to open apps that not in home screen I have to scroll it down but wait,... it don't scroll. Apparently I have to click "all" first and then scroll it down. While it may easy but the problem is I have to highlight "all" first to click it. iPhone have fewer step to go to anything.
The first app I want to open is mail, it's app that make blackberry powerfull among businessman anyway and guess what? It is...
The push feature is great, it delivers email as "send" is clicked, and receives email as soon as the email sent by sender (whoever it is) thank to BIS.
Yeah, blackberry mail is ok but I found facebook for bb is terrible (second apps I opened after mail). Try to read a twenty lines comment and you know what I mean, you read several lines and when you scroll to read next lines, it goes to last lines, and few lines before last line, there is no way to read 'middle' line
....
Sure iPhone can't transfer file via bluetooth, or download music (or anything) outside app store, but it worth it, faster, smoother and I'll stick with it.
http://aravir-rose.blogspot.com
Saturday, December 8, 2012
Mountain Lion's Spotlight didn't Spot Application
Maybe it's just me, after upgrading from leopard to snowleopard to lion and finally mountain lion (always upgrade, no fresh install), this big cat suddenly refuse to index my Application. Whenever I type application name in Spotlight, it just show document, picture but not Application. Typing "macvim" bring me to macvim installation folder, macvim on the web but not Macvim apps. Spotlight setting clearly didn't ban Application folder, so maybe this is another Mountain Lion problem
Still looking for solution...
Still looking for solution...
Mountain Lion's Fullscreen Apps on Extended Display
It seems that weakness of this big cat isn't resolved yet. I used Pages in my Desktop while the big one browsing trough web using safari for refence. When I switch (automatically, bad behaviour I think) to fullscreen on Pages, suddenly the other display become blank (not actually blank, just linen-like wall, or maybe canvas).
Monday, December 3, 2012
Playing with Opacity on HTML5's canvas
What I do here is wrap whole canvas on this program with a rectangle with opacity 0.1. So the code (under script tag) become like this:
var context;
var x=100;
var y=200;
var dx=5;
var dy=5;
var n=10;
var bBola=new Array();
function init(){
canvas=myCanvas;
context= myCanvas.getContext('2d');
for (i=0;i < n;i++){
dx = Math.random()*10-5;
dy = Math.random()*10-5;
bBola.push(new bola('#007700', 11,dx,dy));
}
setInterval(draw,10);
}
function draw(){
for (i=0;i < n;i++){
if (bBola[i].x > = (canvas.width - bBola[i].r) || bBola[i].x < = bBola[i].r) bBola[i].dx *= -1;
if (bBola[i].y > = (canvas.height - bBola[i].r) || bBola[i].y < = bBola[i].r) bBola[i].dy *= -1;
//buat
bBola[i].context.beginPath();
bBola[i].context.fillStyle = bBola[i].color;
bBola[i].context.arc(bBola[i].x,bBola[i].y,bBola[i].r,0,Math.PI*2,false);
bBola[i].context.fill();
//gerak
bBola[i].x+=bBola[i].dx;
bBola[i].y+=bBola[i].dy;
}
context.fillStyle='rgba(255,255,255,.1)';
context.fillRect(0,0,canvas.width,canvas.height);
}
function bola(color, r,dx,dy){
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.r = r;
this.x =Math.random()*400+30;
this.y = Math.random()*250+30;
this.dx = dx;
this.dy = dy;
this.color = color;
}
window.onload = function(){
init()
}
Here the complete html page code
<head>
<script>
var context;
var x=100;
var y=200;
var dx=5;
var dy=5;
var n=10;
var bBola=new Array();
function init(){
canvas=myCanvas;
context= myCanvas.getContext('2d');
for (i=0;i<n;i++){
dx = Math.random()*10-5;
dy = Math.random()*10-5;
bBola.push(new bola('#007700', 11,dx,dy));
}
setInterval(draw,10);
}
function draw(){
for (i=0;i<n;i++){
//pantul
if (bBola[i].x >= (canvas.width - bBola[i].r) || bBola[i].x <= bBola[i].r) bBola[i].dx *= -1;
if (bBola[i].y >= (canvas.height - bBola[i].r) || bBola[i].y <= bBola[i].r) bBola[i].dy *= -1;
//buat
bBola[i].context.beginPath();
bBola[i].context.fillStyle = bBola[i].color;
bBola[i].context.arc(bBola[i].x,bBola[i].y,bBola[i].r,0,Math.PI*2,false);
bBola[i].context.fill();
//gerak
bBola[i].x+=bBola[i].dx;
bBola[i].y+=bBola[i].dy;
}
context.fillStyle='rgba(255,255,255,.1)';
context.fillRect(0,0,canvas.width,canvas.height);
}
function bola(color, r,dx,dy){
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.r = r;
this.x =Math.random()*400+30;
this.y = Math.random()*250+30;
this.dx = dx;
this.dy = dy;
this.color = color;
}
window.onload = function(){
init()
}
</script>
</head>
<body>
<canvas height="300" id="myCanvas" width="500">
</canvas>
</body>
Friday, November 30, 2012
Bouncing Ball using Array on Canvas (without prototype method) in HTML 5
Here the code for this
<head>
<script>
var context;
var x=100;
var y=200;
var dx=5;
var dy=5;
var n=5;
var bBola=new Array();
function init(){
canvas=myCanvas;
context= myCanvas.getContext('2d');
for (i=0;i<n;i++){
dx = Math.random()*10-5;
dy = Math.random()*10-5;
bBola.push(new bola('#007700', 17,dx,dy));
}
setInterval(draw,10);
}
function draw(){
context.clearRect(0,0, 500,300);
for (i=0;i<n;i++){
//pantul
if (bBola[i].x >= (canvas.width - bBola[i].r) || bBola[i].x <= bBola[i].r) bBola[i].dx *= -1;
if (bBola[i].y >= (canvas.height - bBola[i].r) || bBola[i].y <= bBola[i].r) bBola[i].dy *= -1;
//buat
bBola[i].context.beginPath();
bBola[i].context.fillStyle = bBola[i].color;
bBola[i].context.arc(bBola[i].x,bBola[i].y,bBola[i].r,0,Math.PI*2,false);
bBola[i].context.fill();
//gerak
bBola[i].x+=bBola[i].dx;
bBola[i].y+=bBola[i].dy;
}
}
function bola(color, r,dx,dy){
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.r = r;
this.x =Math.random()*400+30;
this.y = Math.random()*250+30;
this.dx = dx;
this.dy = dy;
this.color = color;
}
window.onload = function(){
init()
}
</script>
</head>
<body>
<canvas height="300" id="myCanvas" width="500">
</canvas>
</body>
<head>
<script>
var context;
var x=100;
var y=200;
var dx=5;
var dy=5;
var n=5;
var bBola=new Array();
function init(){
canvas=myCanvas;
context= myCanvas.getContext('2d');
for (i=0;i<n;i++){
dx = Math.random()*10-5;
dy = Math.random()*10-5;
bBola.push(new bola('#007700', 17,dx,dy));
}
setInterval(draw,10);
}
function draw(){
context.clearRect(0,0, 500,300);
for (i=0;i<n;i++){
//pantul
if (bBola[i].x >= (canvas.width - bBola[i].r) || bBola[i].x <= bBola[i].r) bBola[i].dx *= -1;
if (bBola[i].y >= (canvas.height - bBola[i].r) || bBola[i].y <= bBola[i].r) bBola[i].dy *= -1;
//buat
bBola[i].context.beginPath();
bBola[i].context.fillStyle = bBola[i].color;
bBola[i].context.arc(bBola[i].x,bBola[i].y,bBola[i].r,0,Math.PI*2,false);
bBola[i].context.fill();
//gerak
bBola[i].x+=bBola[i].dx;
bBola[i].y+=bBola[i].dy;
}
}
function bola(color, r,dx,dy){
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.r = r;
this.x =Math.random()*400+30;
this.y = Math.random()*250+30;
this.dx = dx;
this.dy = dy;
this.color = color;
}
window.onload = function(){
init()
}
</script>
</head>
<body>
<canvas height="300" id="myCanvas" width="500">
</canvas>
</body>
Supernova: Partikel; batu kokoh di aliran sungai besar fanatisme
Ini bukan spoiler. Hm, atau sebisa mungkin bukan spoiler, :)
Sesore membaca Partikel, dengan Royyan yang tidur pulas disampingku.
Setelah bagian awal yang bikin bulu kuduk meremang dan reflek tangan yang membelai Royyan dengan penuh syukur, pada sekitar pertengahan buku, aku teringat Bodhi, Elektra dan Ksatria.
Aku teringat Bodhi saat direcoki Tristan yang sedang semangat-semangatnya karena baru masuk Buddha (getsul: seseorang yang baru masuk Tibetan Buddhis) dan berencana ke Nepal.
Juga teringat Elektra saat mendengarkan percakapan Daddy 'Super Wija' dengan Watty yang mau masuk Islam.
(Kok tanya Daddy, tanya Tuhan dong? Sudah Dad. Lalu Tuhan bilang apa?)
Juga saat Ksatria bertanya apakah Adam dan Hawa menikah.
Dee, untuk kesekian kalinya, kembali menulis hal-hal yang beberapa penulis lain bahkan tak berani menyentuh atau mendekatinya. Yeah, agama memang hal yang sensitif untuk dibicarakan.
Dee, melalui Zarah, dengan tenang, tanpa pretensi bertanya hal yang sederhana pada Abah,kakeknya. Namun seperti segala pertanyaan yang berhubungan dengan keyakinan, bukan jawaban yang didapat melainkan hidung berdarah dan 'disinheritance'.
Halaman-halaman awal, agak tengah, mengingatkanku akan 'Atheis' karya Achdiat Kartadimaja dan 'The Da Vinci Code'-nya Dan Brown. Sangat tidak baik untuk tekanan darah para penganut fanatik buta (eh, semua fanatik pasti membabi buta ya). Semoga buku ini tidak dicekal atau menuai protes seperti Akar saat memajang aksara suci hindu Omkara di sampul depan (edisi berikutnya, sampul depannya jadi bolong).
Kalaupun iya, setidaknya aku punya versi asli buku ini. Lanjut baca ah,...
Eh, ngganti popoknya Royyan dulu, :)
Sesore membaca Partikel, dengan Royyan yang tidur pulas disampingku.
Setelah bagian awal yang bikin bulu kuduk meremang dan reflek tangan yang membelai Royyan dengan penuh syukur, pada sekitar pertengahan buku, aku teringat Bodhi, Elektra dan Ksatria.
Aku teringat Bodhi saat direcoki Tristan yang sedang semangat-semangatnya karena baru masuk Buddha (getsul: seseorang yang baru masuk Tibetan Buddhis) dan berencana ke Nepal.
Juga teringat Elektra saat mendengarkan percakapan Daddy 'Super Wija' dengan Watty yang mau masuk Islam.
(Kok tanya Daddy, tanya Tuhan dong? Sudah Dad. Lalu Tuhan bilang apa?)
Juga saat Ksatria bertanya apakah Adam dan Hawa menikah.
Dee, untuk kesekian kalinya, kembali menulis hal-hal yang beberapa penulis lain bahkan tak berani menyentuh atau mendekatinya. Yeah, agama memang hal yang sensitif untuk dibicarakan.
Dee, melalui Zarah, dengan tenang, tanpa pretensi bertanya hal yang sederhana pada Abah,kakeknya. Namun seperti segala pertanyaan yang berhubungan dengan keyakinan, bukan jawaban yang didapat melainkan hidung berdarah dan 'disinheritance'.
Halaman-halaman awal, agak tengah, mengingatkanku akan 'Atheis' karya Achdiat Kartadimaja dan 'The Da Vinci Code'-nya Dan Brown. Sangat tidak baik untuk tekanan darah para penganut fanatik buta (eh, semua fanatik pasti membabi buta ya). Semoga buku ini tidak dicekal atau menuai protes seperti Akar saat memajang aksara suci hindu Omkara di sampul depan (edisi berikutnya, sampul depannya jadi bolong).
Kalaupun iya, setidaknya aku punya versi asli buku ini. Lanjut baca ah,...
Eh, ngganti popoknya Royyan dulu, :)
Array and Canvas of HTML5 in Blogger
For some reasons, I wasn't able to display canvas consist of object with array. Dunnow,...
Seeking solution...
UPDATE: It seems blogger didn't support prototype, so I have to improvise my code to adapt it.
Seeking solution...
UPDATE: It seems blogger didn't support prototype, so I have to improvise my code to adapt it.
The Bouncing Ball
The Code for this under the script tag
var context;
var x=100;
var y=200;
var dx=5;
var dy=5;
function init(){
canvas=myCanvas;
context= myCanvas.getContext('2d');
setInterval(draw,10);
bal=new bola('#007700', 17,dx,dy);
}
function draw(){
context.clearRect(0,0, 300,300);
bal.Pantul();
bal.Create();
bal.x+=bal.dx;
bal.y+=bal.dy;
}
function bola(color, r,dx,dy){
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.r = r;
this.x =Math.random()*400+30;
this.y = Math.random()*250+30;
this.dx = dx;
this.dy = dy;
this.color = color;
}
bola.prototype.Create = function (){
this.context.beginPath();
this.context.fillStyle = this.color;
this.context.arc(this.x,this.y,this.r,0,Math.PI*2,false);
this.context.fill();
}
bola.prototype.Pantul = function (){
if (this.x >= (canvas.width - this.r) || this.x <= this.r) this.dx *= -1;
if (this.y >= (canvas.height - this.r) || this.y <= this.r) this.dy *= -1;
}
window.onload = function(){
init()
}
Friday, November 16, 2012
Bouncing Ball using Array in HTML5
I want to create bouncing ball program that's very easy on Flash, Python or Delphi yet very tricky on html5. The program consist of n ball with random velocity (each) moving in a 2d box (oh yeah, square then :) )
I am playing with array in html5 script which is helpful on this program. I don't declare the array using
that come as standart on many language, but prefer
instead, just like list on python. In this program, array's just like container for ball.
In html5, moving an object is a bit tricky and, for some Pascal programmer like me, bringing an old memory of draw-clear-draw-clear... cycle; draw a ball, delete it, draw the same ball but slightly right, delet it, ... and so on. All that kind of tedious job, but it worth for the sake of fast execution and no-need-slow-loading-flash-player thing.
Here's the code under script tag. Keep in mind that many variable's name is in indonesian (ball -> bola, bounce->pantul, collision -> tumbukan )aBola = new array()
that come as standart on many language, but prefer
aBola = []
instead, just like list on python. In this program, array's just like container for ball.
In html5, moving an object is a bit tricky and, for some Pascal programmer like me, bringing an old memory of draw-clear-draw-clear... cycle; draw a ball, delete it, draw the same ball but slightly right, delet it, ... and so on. All that kind of tedious job, but it worth for the sake of fast execution and no-need-slow-loading-flash-player thing.
(to be continued)
//bola:ball
//pantul:bounce
var context;
var n=10;
// membuat bola
function bola(color, r,dx,dy){
this.canvas = canvas;
this.context = canvas.getContext('2d');
this.r = r;
this.x =Math.random()*400+30;
this.y = Math.random()*250+30;
this.dx = dx;
this.dy = dy;
this.color = color;
}
bola.prototype.Create = function (){
this.context.beginPath();
this.context.fillStyle = this.color;
this.context.arc(this.x,this.y,this.r,0,Math.PI*2,false);
this.context.fill();
}
bola.prototype.Pantul = function (){
if (this.x >= (canvas.width - this.r) || this.x <= this.r) this.dx *= -1;
if (this.y >= (canvas.height - this.r) || this.y <= this.r) this.dy *= -1;
}
function init(){
canvas = document.getElementById("myCanvas")
context = canvas.getContext('2d');
// membuat array untuk bola
//create array for ball
aBola = [];
for (i=1;i<=n;i++){
//membuat bola sejumlah n dengan dx dan dy acak
//create n balls with random dx and dy
dx = Math.random()*10-5;
dy = Math.random()*10-5;
aBola.push(new bola('#007700', 17,dx,dy));
}
setInterval(draw,20);
}
function draw(){
context.clearRect(0,0, 500,350);
for (i in aBola) {
//menggerakkan bola
//moving balls
aBola[i].x += aBola[i].dx;
aBola[i].y += aBola[i].dy;
aBola[i].Pantul();
aBola[i].Create();
}
}
Tuesday, November 13, 2012
2D/3D Ball Collision
I used on 1D collission problem where, in case of elastic collision, the ball is changing velocity each other. In 2D/3D case however, the collision is not always head-on collision (which is basically 1 dimension collision).
Head-on
The system above's easy too solve, as simple as interchanging velocity (in elastic case).
Not head-on
Head-on
The system above's easy too solve, as simple as interchanging velocity (in elastic case).
Not head-on
When two balls are in non-head-on collision we could always using transposed new coordinate where both of ball center are on the new x-axis like below
On the new coordinate, we can treat the velocities along x-axis as one dimensional collision case and let go on other component (y, z) intact.
Below's snippet from python code of balls collision detection; the whole code is code of moving many ball on a box.
###deteksi tumbukan antar bola
for i in arange(jumlah):
for j in arange(i+1,jumlah):
jarak=mag(lbola[i].pos-lbola[j].pos)
if jarak<(lbola[i].radius+lbola[j].radius):
arah=norm(lbola[j].pos-lbola[i].pos)
vi=dot(lbola[i].v,arah)
vj=dot(lbola[j].v,arah)
tukar=vj-vi
lbola[i].v=lbola[i].v+tukar*arah
lbola[j].v=lbola[j].v-tukar*arah
pantul=lbola[i].radius+lbola[j].radius-jarak
lbola[i].pos=lbola[i].pos-pantul*arah
lbola[j].pos=lbola[j].pos+pantul*arah
Moving to HTML5
After years fighting the slow loading flash without alternative software, I begin to think seriously about moving to HTML5 coding. Altough it ain't true software for me, it provide what I need mostly: animation.
HTML5 support canvas, audio ad video tag, javascript. Need array data? No problem. If then else? OK.
So, begin...
HTML5 support canvas, audio ad video tag, javascript. Need array data? No problem. If then else? OK.
So, begin...
Subscribe to:
Posts (Atom)
My sky is high, blue, bright and silent.
Nugroho's (almost like junk) blog
By: Nugroho Adi Pramono
323f
(5)
amp
(1)
android
(12)
apple
(7)
arduino
(18)
art
(1)
assembler
(21)
astina
(4)
ATTiny
(23)
blackberry
(4)
camera
(3)
canon
(2)
cerita
(2)
computer
(106)
crazyness
(11)
debian
(1)
delphi
(39)
diary
(286)
flash
(8)
fortran
(6)
freebsd
(6)
google apps script
(8)
guitar
(2)
HTML5
(10)
IFTTT
(7)
Instagram
(7)
internet
(12)
iOS
(5)
iPad
(6)
iPhone
(5)
java
(1)
javascript
(1)
keynote
(2)
LaTeX
(6)
lazarus
(1)
linux
(29)
lion
(15)
mac
(28)
macbook air
(8)
macbook pro
(3)
macOS
(1)
Math
(3)
mathematica
(1)
maverick
(6)
mazda
(4)
microcontroler
(35)
mountain lion
(2)
music
(37)
netbook
(1)
nugnux
(6)
os x
(36)
php
(1)
Physicist
(29)
Picture
(3)
programming
(189)
Python
(109)
S2
(13)
software
(7)
Soliloquy
(125)
Ubuntu
(5)
unix
(4)
Video
(8)
wayang
(3)
yosemite
(3)