<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6758697817819098194</id><updated>2024-09-23T01:55:18.847+01:00</updated><category term="Ruby/ Ruby on Rails"/><category term="Git"/><category term="Linux"/><category term="Processing"/><category term="English"/><category term="Essays and Reports"/><category term="Links"/><category term="Box2D.js"/><category term="Mac"/><category term="MySQL"/><category term="Sass"/><title type='text'>Engineer Flies エンジニアは空を飛ぶ</title><subtitle type='html'>Ruby, The Processing Language　などについてのブログ</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://engineerflies.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6758697817819098194/posts/default/-/Processing'/><link rel='alternate' type='text/html' href='http://engineerflies.blogspot.com/search/label/Processing'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/01700091790800160715</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6758697817819098194.post-7949146972056335208</id><published>2014-01-05T05:27:00.000+00:00</published><updated>2014-01-05T05:38:35.221+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Processing"/><title type='text'>ProcessingでSocial Graphを作る</title><content type='html'>ProcessingでSocail Graphを作ってみました。自分とその友達同士の共通の友人の数を線の太さに表したソーシャルグラフです。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://www.diigo.com/item/p/qpeeeqszbsebdpdorzbcebboep&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://www.diigo.com/item/p/qpeeeqszbsebdpdorzbcebboep&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
世にいろんなソーシャルグラフのライブラリがあるのでそれらを使えば一瞬なんだろうけど幾何学的なことを理解したくて、本を読みながら部品から一個一個全部作りました。詳しくは書かないけれどこんな感じのテクニックを使っています。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;正N角形&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;三角関数 cos, sin&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;ベジェ曲線&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
# コントロール的なロジックはSocialGraphというclassに集約されていて、引数はcsvファイルと、半径です。&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;span class=&quot;n&quot; style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; line-height: 14.545454025268555px; white-space: pre;&quot;&gt;SocialGraph&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; font-weight: bold; line-height: 14.545454025268555px; white-space: pre;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; line-height: 14.545454025268555px; white-space: pre;&quot;&gt;SocialGraphCsv&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; line-height: 14.545454025268555px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; line-height: 14.545454025268555px; white-space: pre;&quot;&gt;csv&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; font-weight: bold; line-height: 14.545454025268555px; white-space: pre;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; line-height: 14.545454025268555px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kt&quot; style=&quot;background-color: white; color: #445588; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; font-weight: bold; line-height: 14.545454025268555px; white-space: pre;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; line-height: 14.545454025268555px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; line-height: 14.545454025268555px; white-space: pre;&quot;&gt;radius&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; font-weight: bold; line-height: 14.545454025268555px; white-space: pre;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; line-height: 14.545454025268555px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
こういうCSVを渡すとカラム数を拾って自動的に正N角形を描写して、人名や線を描写してくれます。&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;span style=&quot;background-color: white; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; line-height: 14.545454025268555px; white-space: pre;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/another&gt;&lt;/person&gt;&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;table border=&quot;1&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;border: solid 1 #FFFFAA; width: 770px;&quot;&gt;&lt;!--StartFragment--&gt;  &lt;colgroup&gt;&lt;col span=&quot;10&quot; style=&quot;width: 77pt;&quot; width=&quot;77&quot;&gt;&lt;/col&gt;  &lt;/colgroup&gt;&lt;tbody&gt;
&lt;tr height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;   &lt;td height=&quot;18&quot; style=&quot;height: 18.0pt; width: 77pt;&quot; width=&quot;77&quot;&gt;&lt;/td&gt;   &lt;td style=&quot;width: 77pt;&quot; width=&quot;77&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Tatsuya Suzuki&lt;/span&gt;&lt;/td&gt;   &lt;td style=&quot;width: 77pt;&quot; width=&quot;77&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Emi Ito&lt;/span&gt;&lt;/td&gt;   &lt;td style=&quot;width: 77pt;&quot; width=&quot;77&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Bruno Barroso&lt;/span&gt;&lt;/td&gt;   &lt;td style=&quot;width: 77pt;&quot; width=&quot;77&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Mattew Day&lt;/span&gt;&lt;/td&gt;   &lt;td style=&quot;width: 77pt;&quot; width=&quot;77&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Maxim Dokhlov&lt;/span&gt;&lt;/td&gt;   &lt;td style=&quot;width: 77pt;&quot; width=&quot;77&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Mehmet Bagbekleyen&lt;/span&gt;&lt;/td&gt;   &lt;td style=&quot;width: 77pt;&quot; width=&quot;77&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Alex Yixnitsky&lt;/span&gt;&lt;/td&gt;   &lt;td style=&quot;width: 77pt;&quot; width=&quot;77&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Stuart Gardner&lt;/span&gt;&lt;/td&gt;   &lt;td style=&quot;width: 77pt;&quot; width=&quot;77&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Derrick May&lt;/span&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;   &lt;td height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Tatsuya Suzuki&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;50&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;19&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;10&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;9&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;11&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;15&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;   &lt;td height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Emi Ito&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;3&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;3&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;   &lt;td height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Bruno Barroso&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;4&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;3&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;17&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;   &lt;td height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Mattew Day&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;4&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;5&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;   &lt;td height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Maxim Dokhlov&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;4&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;   &lt;td height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Mehmet Bagbekleyen&amp;nbsp;&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;2&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;   &lt;td height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Alex Yixnitsky&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;   &lt;td height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Stuart Gardner&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;1&lt;/span&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;tr height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;   &lt;td height=&quot;18&quot; style=&quot;height: 18.0pt;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;Derrick May&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;   &lt;td align=&quot;right&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;0&lt;/span&gt;&lt;/td&gt;  &lt;/tr&gt;
&lt;!--EndFragment--&gt; &lt;/tbody&gt;&lt;/table&gt;
&lt;/another&gt;&lt;/person&gt;&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/another&gt;&lt;/person&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;span style=&quot;background-color: white; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 11.818181991577148px; line-height: 14.545454025268555px; white-space: pre;&quot;&gt;総当たり（隣接配列）のため下半分は上半分の繰り返しであるため全て０です。1は共通の友人が私しかいないことを意味しています。&lt;/span&gt;&lt;/another&gt;&lt;/person&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
共通の友人の数は以下のURLで取得できます&lt;br /&gt;
https://www.facebook.com/&amp;lt;person A&amp;gt;&lt;person a=&quot;&quot;&gt;?and=&amp;lt;person B&amp;gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;br /&gt;&lt;/another&gt;&lt;/person&gt;&lt;br /&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;           &lt;/another&gt;&lt;/person&gt;&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;br /&gt;&lt;/another&gt;&lt;/person&gt;&lt;br /&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;br /&gt;&lt;/another&gt;&lt;/person&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;# クラス構成&lt;/another&gt;&lt;/person&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;SocailGraph: 統括コントローラ&lt;/li&gt;
&lt;li&gt;Coordinate: 座標を保持する&lt;/li&gt;
&lt;li&gt;EquilateralPolygon: 等辺三角形を描写する&lt;/li&gt;
&lt;li&gt;nodeNames: ノード（Facebookの例だと）の名前&lt;/li&gt;
&lt;li&gt;FamiliarityAsLine: 親しさを線（の太さ）で表します&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
nodeNamesとFamiliarityAsLineはEquilateralPolygonに依存していますが、それぞれ独立した画像として再利用可能です。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;br /&gt;&lt;/another&gt;&lt;/person&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;# ソースコード&lt;/another&gt;&lt;/person&gt;&lt;/another&gt;&lt;/person&gt;&lt;br /&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;br /&gt;&lt;/another&gt;&lt;/person&gt;&lt;/another&gt;&lt;/person&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;まだ整えられそう。ProcessingでOOPする難しさなんかも&lt;a href=&quot;http://engineerflies.blogspot.jp/2014/01/processing.html&quot;&gt;過去の記事&lt;/a&gt;にまとめました。&lt;/another&gt;&lt;/person&gt;&lt;/another&gt;&lt;/person&gt;&lt;br /&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;br /&gt;&lt;/another&gt;&lt;/person&gt;&amp;lt;script src=&quot;https://gist.github.com/suzukimilanpaak/8264451.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/another&gt;&lt;/person&gt;&lt;br /&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;br /&gt;&lt;/another&gt;&lt;/person&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;br /&gt;&lt;/another&gt;&lt;/person&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;# 感想&lt;/another&gt;&lt;/person&gt;&lt;br /&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;br /&gt;&lt;/another&gt;&lt;/person&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;java(Processing Language)を久しぶりに書いたけど、今更OOPを気軽にやれない感じだった。ProcessingでOOPしようとするのが結構めんどくさい（不可能ではない）。ので再利用制のあるコードを書いて共有するのがProcessingの世界では手間。Javaの最近の文法を知らないけど、あの言語にあるこんなしようを使えばもっと奇麗になるかも。&lt;/another&gt;&lt;/person&gt;&lt;br /&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;br /&gt;&lt;/another&gt;&lt;/person&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;ソーシャルグラフは&lt;/another&gt;&lt;/person&gt;三角関数とπの組み合わせしか使わないので意外と簡単。&lt;br /&gt;
&lt;br /&gt;
&lt;person a=&quot;&quot;&gt;&lt;another b=&quot;&quot; person=&quot;&quot;&gt;&lt;br /&gt;&lt;/another&gt;&lt;/person&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6758697817819098194/posts/default/7949146972056335208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6758697817819098194/posts/default/7949146972056335208'/><link rel='alternate' type='text/html' href='http://engineerflies.blogspot.com/2014/01/processingsocial-graph.html' title='ProcessingでSocial Graphを作る'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/01700091790800160715</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-6758697817819098194.post-878492587399306101</id><published>2014-01-03T09:54:00.001+00:00</published><updated>2014-01-03T10:00:45.732+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Processing"/><title type='text'>Processingで正多角形を描く</title><content type='html'>&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ9oJIMvfornguBMW7Fin8dzfSYcutrYsyeTnavXIVYfz97PIdnbz3BoBcCkwMUDi8Eyd0pnibvDTorz0mpqJF-I7Y1qdoh1AkSdOLWOZkQEciDCWZ-bccsOt-g44P02FaK8drhyPMQ2pz/s1600/result.jpg&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ9oJIMvfornguBMW7Fin8dzfSYcutrYsyeTnavXIVYfz97PIdnbz3BoBcCkwMUDi8Eyd0pnibvDTorz0mpqJF-I7Y1qdoh1AkSdOLWOZkQEciDCWZ-bccsOt-g44P02FaK8drhyPMQ2pz/s320/result.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
最近Processingで久々に遊んでいます。以前はライブラリを組み合わせて”わーできたー”位のことをやっておりましたが、最近基礎力を身につけたいと思って幾何学的なことも軽く学んでいます。&lt;br /&gt;
さて、文化というかよく見かけるProcessingのサンプルは縦に長ーくて変数の値がなんだったのか途中から忘れてしまうようなものが多いです。&lt;br /&gt;
例えば折れ線グラフを書くようなケースの場合、&lt;br /&gt;
&lt;br /&gt;
統計情報をデータソースから取得する　＞　X軸、Y軸を描く　＞　X、Yの最大値を求めてスケールを決める　＞　ちょうどいい単位に目盛りを引く　＞　折れ線グラフを描く&lt;br /&gt;
&lt;br /&gt;
といったステップを分けて踏むとコードがすっきりするのですが、一方でX軸、Y軸のディスプレイ上の座標や、XやYの最大値やなどの変数はスケッチを通して保持したいもので、そのことが縦に長ーいプログラムだとコードを複雑にしがちです。Proceccingの世界だとおそらく一回使い切りのプロジェクトもしくは次回使うことがあってもコピペして修正すれば割とすんでしまうようなことが多いのかもしれません。&lt;br /&gt;
&lt;br /&gt;
でも、やっぱり再利用可能な部品を作りたいですね。コードを関数に区切ると変数のスコープが狭まるのでミニマムなことにフォーカスできます。&lt;br /&gt;
&lt;br /&gt;
下記のコードでは最初に以下の引数で図形を調整できるものという条件を固持するものとして書きました。&lt;br /&gt;
&lt;br /&gt;
- 正N角形のN&lt;br /&gt;
- 半径&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# どこから読めばいいのか？&lt;br /&gt;
まずはsetupとdrawを読んでください。特にdrawを読むことで大まかな流れがつかめるでしょう。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;// 半径２００pxの６角形を描く
  polygon = new EquilateralPolygon(6, 200);
  // 頂点を取得
  polygon.vertexes();
  // 頂点を描く
  polygon.drawVertexes();
  // 番号を描く
  polygon.drawIndexes();
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
肝になるところだけ軽く触れておきましょう。&lt;br /&gt;
&lt;br /&gt;
# #xVertex, #vertexes()&lt;br /&gt;
&lt;br /&gt;
vertexesは頂点の座標を集めています。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;java&quot; name=&quot;code&quot;&gt;public float xVertex(int i, int extra) {
    return cos(angles[i]) * (radius + extra);
  }

  public Coordinate[] vertexes() {
    vertexes = new Coordinate[numVertexes];
    float angleForSingleArc = 2 * PI / numVertexes;
  
    for(int i = 0; i &amp;lt; numVertexes; i++) {
      // Sum up angles
      angles[i] = HALF_PI - angleForSingleArc * i;
      
      float x = xVertex(i, 0);
      float y = - yVertex(i, 0);
      
      vertexes[i] = new Coordinate(x, y);
    }
    
    return vertexes;
  }
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
ある頂点のX座標は三角関数を使って以下のように求められます。&lt;a href=&quot;http://www8.plala.or.jp/ap2/suugaku/sankakukansuunoshoho.html#sincoskoushiki&quot;&gt;sinとcosを使った辺の長さの求め方&lt;/a&gt;    &lt;br /&gt;
&lt;br /&gt;
# xVertex   &lt;br /&gt;
&lt;br /&gt;
cos(角度) * 半径  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
y座標はsinを使って以下のように求められます   &lt;br /&gt;
&lt;br /&gt;
# yVertex&lt;br /&gt;
sin(角度) * 半径  &lt;br /&gt;
&lt;br /&gt;
xVertex中では半径だけを使ってって計算しています。これは円の中心を起点の0,0としてその差分を座標として計算し描写しているからです。ただ描写する正確な座標ははプログラマが意識しないですむように&lt;a href=&quot;https://gist.github.com/suzukimilanpaak/8234344#file-draw_equilateral_polygon-pde-L94&quot;&gt;translate関数であらかじめずらしています&lt;/a&gt;。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
＃ 拡張点の座標の求め方&lt;br /&gt;
angles[i] = HALF_PI - angleForSingleArc * i;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
PIはπを意味するあらかじめProcessingに用意された定数です。上記のx, yの関数で角度が0の場合processingは右端になります。そこから始まって反時計回りに角度を表します。  &lt;br /&gt;
&lt;br /&gt;
0 =&amp;gt; QUARTER_PI（４５度） =&amp;gt; HALF_PI（９０度） =&amp;gt; PI(180度) =&amp;gt; 2 * PI(360度)   &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH-1ayYph2B1uSFaEQ3QndPDyc7b37C41G_7BfhnWms82Dm5aLbBZoAalQKWmtt_3E7APdJLV_fUBEz0VPgcCFJ7iTvPmmXNsnT8PnI6y0q641q7j3G9uy5ciptoL5AUOb-4uZhYI3RKJQ/s1600/PI+of+Processing++(2).png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgH-1ayYph2B1uSFaEQ3QndPDyc7b37C41G_7BfhnWms82Dm5aLbBZoAalQKWmtt_3E7APdJLV_fUBEz0VPgcCFJ7iTvPmmXNsnT8PnI6y0q641q7j3G9uy5ciptoL5AUOb-4uZhYI3RKJQ/s320/PI+of+Processing++(2).png&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
一つずつの頂点について図の一番上を起点としてそこからの角度をi毎に取得します。時計回りに点を配置することにしたので マイナスを付けて逆方向に回転させます。 &lt;br /&gt;
angles[i] = HALF_PI - angleForSingleArc * i;&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/suzukimilanpaak/8234344.js&quot;&gt;&lt;/script&gt;   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
＃　なぜOOPを使ってシンプルに書くのが難しいのか？&lt;br /&gt;
&lt;br /&gt;
なぜProcessingではOOPをつかってシンプルに書くのがむずかしいのでしょうか？コードを書いていて思ったことがあります。&lt;br /&gt;
&lt;br /&gt;
- 文脈依存の関数が多い&lt;br /&gt;
&lt;br /&gt;
例えばこのコードに出てくる以下のようなコードは文脈依存です&lt;br /&gt;
&lt;br /&gt;
fill(BLACK);&lt;br /&gt;
text(i, vertexes[i].x, vertexes[i].y);&lt;br /&gt;
noFill();&lt;br /&gt;
&lt;br /&gt;
noLoop()&lt;br /&gt;
&lt;br /&gt;
translate(DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
全て後述の処理に影響します。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- 一個のループに何でもまとめてしまう&lt;br /&gt;
&lt;br /&gt;
計算量が気になってしまい一個のループに何でもまとめてしまうのでそのループを含む関数がいろんなことをやってしまいがちです。lambdaを使ってループのある関数内で座標計算や描写などを遅延評価させてあげればいいんですかね。&lt;br /&gt;
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/Lambda-QuickStart/index.html?cid=7180&amp;ssid=3993398328344#section2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
以上、久々のJava勉強になりました。&lt;br /&gt;
</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6758697817819098194/posts/default/878492587399306101'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6758697817819098194/posts/default/878492587399306101'/><link rel='alternate' type='text/html' href='http://engineerflies.blogspot.com/2014/01/processing.html' title='Processingで正多角形を描く'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/01700091790800160715</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJ9oJIMvfornguBMW7Fin8dzfSYcutrYsyeTnavXIVYfz97PIdnbz3BoBcCkwMUDi8Eyd0pnibvDTorz0mpqJF-I7Y1qdoh1AkSdOLWOZkQEciDCWZ-bccsOt-g44P02FaK8drhyPMQ2pz/s72-c/result.jpg" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-6758697817819098194.post-7647687199834389133</id><published>2014-01-02T12:52:00.001+00:00</published><updated>2014-02-27T13:31:07.727+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Processing"/><title type='text'>データビジュアライゼイションに役立つかもしれないデータソースまとめ</title><content type='html'>データビジュアライゼイションに役立つかもしれないデータソースをまとめてみます。まだ少ないですが後からもちょいちょい足していきます。(*.最終更新日 2014.1.2)まとまってないだろっていう突っ込みは来年までお待ちください。&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;# 統計データ&lt;/span&gt;&lt;/h2&gt;
＜日本＞&lt;br /&gt;
# &lt;a href=&quot;http://www.e-stat.go.jp/SG1/estat/eStatTopPortal.do&quot;&gt;estat&lt;/a&gt;, &lt;a href=&quot;http://www.e-stat.go.jp/SG1/estat/statisticsLinkView.do?method=init&quot;&gt;省庁別&lt;/a&gt;&lt;br /&gt;
人口や産業、経済、エネルギーに関する政府の統計情報。国勢調査などのデータがある。&lt;br /&gt;
&lt;br /&gt;
# &lt;a href=&quot;http://datameti.go.jp/&quot;&gt;Data Meti&lt;/a&gt;&lt;br /&gt;
経済産業省がオープンデータを実践するために設置した試験サイト。予算、決算、技術、食品、地理、防災などの情報がある。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
＜世界＞&lt;br /&gt;
# &lt;a href=&quot;http://www.imf.org/external/data.htm&quot;&gt;IMF&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
# 地図&lt;/h2&gt;
&lt;div&gt;
地図のマッピングをするときはデータソースの緯度、経度を正確に地図に配置しなければなりません。そのためには背景にある地図のイメージの緯度、経度が正確でないとなりませんね。&lt;br /&gt;
&lt;br /&gt;
-&amp;nbsp;&lt;a href=&quot;http://www.openstreetmap.org/export#map=5/47.828/7.668&amp;amp;layers=H&quot;&gt;openStreetMap&lt;/a&gt;&lt;br /&gt;
　開かれたライセンスの&lt;a href=&quot;http://www.openstreetmap.org/export#map=5/47.828/7.668&amp;amp;layers=H&quot;&gt;openStreetMap&lt;/a&gt;では緯度経度の範囲によって地図を切り取ることが出来ます。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://www.diigo.com/item/p/qpeeeqszbsdsdqerszbceabaor&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;172&quot; src=&quot;https://www.diigo.com/item/p/qpeeeqszbsdsdqerszbceabaor&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
緯度、経度はよく&lt;a href=&quot;http://www.gsi.go.jp/KOKUJYOHO/center.htm&quot;&gt;度、分、秒で表されます&lt;/a&gt;。度より小さい値は６０進数で表されます。分は６０で割り、秒は３６００で割りその値を足すことで小数点以下の値に変換することが出来ます。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-&amp;nbsp;&lt;a href=&quot;http://www.qgis.org/ja/site/index.html&quot;&gt;QGIS&lt;/a&gt;&lt;br /&gt;
QGISは地図上に必要なレイヤー(georeferrence？)を配置するOSSです。商業利用は有料です。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6758697817819098194/posts/default/7647687199834389133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6758697817819098194/posts/default/7647687199834389133'/><link rel='alternate' type='text/html' href='http://engineerflies.blogspot.com/2014/01/blog-post.html' title='データビジュアライゼイションに役立つかもしれないデータソースまとめ'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/01700091790800160715</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-6758697817819098194.post-3846104398021200923</id><published>2010-02-10T23:03:00.003+00:00</published><updated>2010-02-13T22:43:57.888+00:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Processing"/><title type='text'>Processing on Ubuntu</title><content type='html'>手持ちのラップトップSamsung nc10のOSをwin XPからubuntuに入れ替えたのでProcessingの環境を再構築。&lt;br /&gt;
&lt;br /&gt;
- processingのインストール&lt;br /&gt;
- よく使うライブラリのインストール&lt;br /&gt;
- JMyron&lt;br /&gt;
&lt;br /&gt;
当方のOSはubuntu 9.10 karmic&lt;br /&gt;
&lt;pre class=prettyprint&gt;$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION=&quot;Ubuntu 9.10&quot;
&lt;/pre&gt;&lt;br /&gt;
&lt;h1&gt;processingのダウンロード、インストール&lt;/h1&gt;&lt;br /&gt;
&lt;a href=http://processing.org/download/&gt;本家のダウンロードページ&lt;/a&gt;に常に最新版のダウンロードリンクがあります。リンクアドレスをコピーしてください。&lt;br /&gt;
&lt;pre class=prettyprint&gt;$ wget http://processing.org/download/processing-1.0.9.tgz
$ tar xvzf processing-1.0.9.tgz
$ sudo mv processing-1.0.9 /opt/processing-1.0.9
&lt;/pre&gt;これだけです。&lt;br /&gt;
&lt;br /&gt;
JREはprocessing直下のjavaフォルダに入ってるみたいなので別途インストール必要無いみたいです。&lt;br /&gt;
&lt;br /&gt;
早速起動してみましょう&lt;br /&gt;
$ /opt/processing-1.0.9/processing&lt;br /&gt;
&lt;br /&gt;
動作確認はFile-&gt;Examples以下のサンプルから。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;JMyronのインストール&lt;/h1&gt;&lt;br /&gt;
JMyronのインストールも&lt;a href=http://webcamxtra.sourceforge.net/download.shtml&gt;本家から最新を取得。&lt;/a&gt;ここからはGUIで操作します。解答すると、HowtoInstall.txtというファイルがあるのでそれにしたがいます。&lt;br /&gt;
- Jmyronフォルダは先ほど配置したprocessingのホームディレクトリのしたのlibrariesディレクトリに移動&lt;br /&gt;
- Jmyron Examplesはprocessingのexamplesディレクトリに移動&lt;br /&gt;
&lt;br /&gt;
librariesディレクトリは名前のとおりライブラリ群が配置されたディレクトリ。processingが参照パスが通ってます。先ほど動作確認を行ったとおりProcessingのメニューからexamplesディレクトリ以下のサンプルが参照可能です。私の場合メニューがExample&gt;&gt;JMyron Examlesとなるのが何だか気になってでディレクトリ名をJMyronに変更してます。&lt;br /&gt;
&lt;br /&gt;
processingを再起動してFile-&gt;Examples-&gt;JMyron以下のサンプルを実行しようとするとJMyronをnewするステップで落ちます。soとそれにあわせたjarを配布しているページが&lt;a href=http://piratestudios.com/v4ljmyron/&gt;こちら&lt;/a&gt;に有ります。ありがたいですね。日付リンクから最新版を取得します。&lt;br /&gt;
&lt;br /&gt;
READMEにはJMyron.jarをprocessing/java/libにlibJMyron.soをprocessing/java/lib/i386に配置するように書いてありますが、両方共processing/libraries/JMyron/libraryに配置すれば動作します。 - パスが通っているみたいなので。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
っと、ここまでやってprocessing.video.*が動かないことが判明。”Linux 向けの Processing には processing.video 自体が入ってない。”いやあほんとQuickTimeとか爆発してほしいですな。同感 &lt;br /&gt;
ビデオの操作がしたい方はこちらを参考にしてください。&lt;a href=http://techno-st.net/2009/11/05/processing-video-on-linux-1.html&gt;Processing video on Linux&lt;/a&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6758697817819098194/posts/default/3846104398021200923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6758697817819098194/posts/default/3846104398021200923'/><link rel='alternate' type='text/html' href='http://engineerflies.blogspot.com/2010/02/processing-on-ubuntu.html' title='Processing on Ubuntu'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/01700091790800160715</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>