Emotion Changer

Name: Jiyoung You (puretomato@Gmail.com)
Math 213 -- Mathematics with Mathematica, Fall 2009 
December 3, 2009

Abstract

How to make feel easy to understand some concepts of Mathematica such as Manipulate, Using basic tools of mathematica without using hard mathematic skills? I would like to recommend this program not only math majoring student but also secondary and elementary student. I used manipulating for my mini - project (It was mean value theorem). However, it was based on the math theorem and I want to show this project to random people who doesn’ t have math back ground can be able to understand manipulating. In addition, I used “Switch” to make each emotional status, and Disk, Polygan, Rectangle, Sin and two degree function to create these shapes.

Section 1. Introduction

1.1 Background

I thought Mathematica tool can be used most likely for solving math problems. I saw couple of fancy project with pictures before, I, however thought this is for professional programmer, but I realized I could draw some couple of simple shapes and create simple pictures and make it interesting. It is based on math solving with many variables but it is not hard to understand because it’ s not a math graph, it’ s a simple and funny picture.

1.2 Problem Statement

The problem statement I answer is
: I wanted to draw the face which looks familiar with us, then I want these to move and changing emotion itself with manipulating.This can be one of the way to understand Mathematica easily.

1.3 Useful Commands

: First of all I use Disk, and Polygon to create the shape of my face. I realize I can draw lots of things with Mathematica program. Especially, I used polygon to make glasses, tear, and hat etc. I draw round face and two eyes with disk. I tried circle to draw face first, it didn’ t filled inside of the circle and I found the “disk” later on and I used it. I would like to mention how to use the polygon. If you look at the definition and basic formulas for polygon and it is not hard to draw it, but you need to be careful, it has to be in right order and right number of the points. 
  Secondly, I use “Switch” to make a button on the pictures. It was complicated and makes me much confused every time I adding up each pieces on the faces. For example I putting in glasses on the first face, but it made my all project got mass, so I tried many time to make this button.
  Lastly, manipulating was not easy at all. I used manipulating couple of times already, but it was still hard for me. I made mistakes many times and changing position of variables many times Since I had many variables in one manipulate, changing  eyes, lips, eye brows position, changing color and expression of the face.

?Manipulate

?Switch

?Graphics

?Show

?Disk

?Polygon

1.4 File Structure

This project will show how to draw the face, and how each pieces move, In section 2.1 I tried to draw the basic faces with using disk and y=(x^2) function, and section 2.2, 2.3 I tried to draw different emotional face, which are sad, and angry. I additionally draw tear, sunglasses to give more emotional express. The last part is manipulating. This manipulating can be represent this each of pieces can move, and it will create random various emotional expressions when you manipulating everything at the same time otherwise the auto-run will work to make it.

Section 2. Main Work

Basically, My project has two parts wich are Switch and Manipualting. Before I get to the Switch and Manipulating, I need to draw the faces and each emotional face to put into Swtich. As I mentioned above, I used Manipulate, Switch, Graph, and Show.  Addition, Disk, Morgan, Rectangle, and two degree function(y=(x^2) )to create face shapes.

2.1 Draw Smile Face

I tried to draw smile face, and these are each piece that I made up before I put in to “Show”. First I tried to draw yellow face, but the code "circle" gave me only the circle and it wasn't filled with color, I just want to show comapring example with "Disk". Two black disk will become eyes on this face, and y=(x^2) will become a mouth on smile face.

Graphics[{Orange,Circle[{0,0},.1],Black}](*First I tried to use circle, but it didn't filled it. I just want to show as example*)

Graphics[{Yellow,Disk[{0,0},.1],Black}](*Face-Yello Disk*)

Graphics[{Black,Disk[{-0.3,0.5},0.2], Black,Disk[{0.3,0.5},0.2]}](*Eyes-Two black disks*)

Show[Plot[x^2-0.3,{x,-0.2,0.2},PlotStyle->Orange]](*y=(x^2) would represent Smile mouth*)

Show[Graphics[{Yellow,Disk[{0,0},1],Black,Disk[{-0.3,0.5},0.2],Black,Disk[{0.3,0.5},0.2],White,Line[{{-2,-2},{-2,2},{2,2},{2,-2},{-2,-2}}]}],Plot[a^2-0.4,{a,-0.4,0.4},PlotStyle->{Black,Thick}],ImageSize->500]

2.2 Draw Sad Face

The sad face has been said the mouth usually going down, and I tried to make it with y=-(x^2)and I added a tear using polygon and disk.

Show[Plot[-x^2-0.3,{x,-0.2,0.2},PlotStyle->Orange]](*Sad Mouth*)

Graphics[Polygon[{{0.5,0.2},{0.55,0},{0.45,0}}]](*Polygon.Why I need this for?*)

Graphics[{Lighter[Blue],Disk[{0.5,0},.05],Lighter[Blue],Polygon[{{0.5,0.2},{0.55,0},{0.45,0}}]}](*tear-polygon and I added one disk.*)

Show[Graphics[{
Black,Disk[{0,0},1],White,Disk[{-0.3,0.5},0.2],White,Disk[{0.3,0.5},0.2],Line[{{-2,-2},{-2,2},{2,2},{2,-2},{-2,-2}}],
Lighter[Blue],Disk[{0.5,0},.05],Lighter[Blue],Polygon[{{0.5,0.2},{0.55,0},{0.45,0}}]}
],Plot[-a^2-0.2,{a,-0.4,0.4},PlotStyle->{White,Thick}],ImageSize->500](*Chaning color to black, using -a^2 fuction to make mouth be sad and adding tear*)

Manipulate[Show[Graphics[{
Black,Disk[{0,0},1],White,Disk[{-0.3,0.5},0.2],White,Disk[{0.3,0.5},0.2],Line[{{-2,-2},{-2,2},{2,2},{2,-2},{-2,-2}}],
Lighter[Blue],Disk[{0.5,0+z},.05],Lighter[Blue],Polygon[{{0.5,0.2+z},{0.55,0+z},{0.45,0+z}}]}
],Plot[-a^2-0.2,{a,-0.4,0.4},PlotStyle->{White,Thick}],ImageSize->500],{{z,0,"Tear Position"},0,.1}](*Make another variables for "z" and the tear can move as "z" moves*)

2.3 Draw Angry Face

Show[Graphics[{Red,Disk[{0,0},1],Black,Disk[{-0.3,0.4},0.2], Black,Disk[{0.3,0.4},0.2],Black,Thick,Line[{{-.45-.1,.6+.1},{-0.15,.6}}],Line[{{.15,.6},{.45+.1,.6+.1}}],White,Line[{{-2,-2},{-2,2},{2,2},{2,-2},{-2,-2}}]}],
Plot[-1a^2-0.4,{a,-0.4,0.4},PlotStyle->{Black,Thick}],ImageSize->500](*Chaning color to Red and adding line to create two lines for eye brows and make it going up*)

2.4 Draw Sunglasses

Show[Graphics[{Polygon[{{-.4,.3},{-.1,.3},{-.1,.6},{-.6,.6}}],Polygon[{{.1,.3},{.4,.3},{.6,.6},{.1,.6}}],
Black,Thick,Line[{{-.1,.6},{.1,.6}}]}]](*Use Polygon and draw thick line between two polygons*)

2.5 Using "Switch"

Manipulate[
Switch[x,
Smile,Show[Graphics[
{Yellow,Disk[{0,0},1],
Black,Disk[{-0.3,0.5},0.1],
Black,Disk[{0.3,0.5},0.1],
White,Line[{{-2,-2},{-2,2},{2,2},{2,-2},{-2,-2}}],(*Adding Sunglasses when smile*)
Black,Opacity[y],
Polygon[{{-.4,.3},{-.1,.3},{-.1,.6},{-.6,.6}}],
Polygon[{{.1,.3},{.4,.3},{.6,.6},{.1,.6}}],
Black,Thick,Line[{{-.1,.6},{.1,.6}}]}],(*Smile face*)
Plot[a^2-0.4,{a,-0.4,0.4},PlotStyle->{Black,Thick}],ImageSize->500],
Sad,Show[Graphics[{
Black,Disk[{0,0},1],White,Disk[{-0.3,0.5},0.2],White,Disk[{0.3,0.5},0.2],Line[{{-2,-2},{-2,2},{2,2},{2,-2},{-2,-2}}],
Lighter[Blue],Disk[{0.5,0},.05],Lighter[Blue],Polygon[{{0.5,0.2},{0.55,0},{0.45,0}}]}
],Plot[-a^2-0.2,{a,-0.4,0.4},PlotStyle->{White,Thick}],ImageSize->500],(*Sad face*)
Angry,Show[Graphics[{Red,Disk[{0,0},1],Black,Disk[{-0.3,0.4},0.2], Black,Disk[{0.3,0.4},0.2],Black,Thick,Line[{{-.45-.1,.6+.1},{-0.15,.6}}],Line[{{.15,.6},{.45+.1,.6+.1}}],White,Line[{{-2,-2},{-2,2},{2,2},{2,-2},{-2,-2}}]}],
Plot[-1a^2-0.4,{a,-0.4,0.4},PlotStyle->{Black,Thick}],ImageSize->500]],(*Angry face*)
{{x,Smile,"Face"},{Smile,Sad,Angry}},{{y,0,"Glasses"},{0,0.5},ControlType->Checkbox}](*Switch Type*)

2.6 Manipualting

Now, I need to manipulate each piece to move as variables move. The emotion will be change as these values change. It will appear eye size, position, lip size, position, Facial expression is getting increasing and decreasing.I set up the color list for face. before manipualting, and make variable "i"  and then the i goes 1 to 8 and addtional 1 means the color chage as each numer changes, and it can't show between numbers otherwise it shows error message. I added hair with commend line. Additional commend: Control Type, if and loops statement.

Colors={Red, Yellow,Blue,Orange,Green,Purple,Pink,Brown};(*facial color list*)

Manipulate[
Show[Graphics[{
Black,Thick,Line[{{0,1},{0,1.25}}],(*hair*)
Line[{{0.3,Sqrt[1-0.3^2]},{0.5,Sqrt[1.25^2-0.5^2]}}],(*hair*)
Line[{{-0.3,Sqrt[1-0.3^2]},{-0.5,Sqrt[1.25^2-0.5^2]}}],(*hair*)
Line[{{0.5,Sqrt[1-0.5^2]},{0.7,Sqrt[1.25^2-0.7^2]}}],(*hair*)
Line[{{-0.5,Sqrt[1-0.5^2]},{-0.7,Sqrt[1.25^2-0.7^2]}}],(*hair*)
Colors[[i]],Disk[{0,0},{e,f}],(*Facial color changing*)
Black,Disk[{-0.3-x,0.5+x+d-c},{g,h}],(*Left side eye*)
Black,Disk[{0.3+x,0.5+x+d-c},{g,h}],(*Right side eye*)
Black,Thick,
Line[{{-.45+c-x,.6+c+x},{-0.15+d-x,.6+d+x}}],Line[{{.15-d+x,.6+d+x},{.45-c+x,.6+c+x}}]}],(*Inner outereye brows position movement*)Plot[1/10*Sin[p*a]+b*a^2-0.4,{a,-0.4,0.4},PlotStyle->{Black,Thick}],Axes->o],(*Lip twisted*)
{{i,1,"Face Color"},1,8,1},(*Swtich->"face color"*)
{{x,0,"Eye Position"},0,0.15},(*Switch->"eye position"*)
{{b,1,"Lips Position"},1,-1,-0.01},(*Switch->"Lips position"*)
{{c,0,"Outer Eye Brow Movement"},0,.1},(*Switch->"outer eye brow movemnet"*)
{{d,0,"Inner Eye Brow Position"},0,-.1},(*Switch->"eye brow position"*)
{{e,1,"Facial Expression x-axes"},0.8,2},(*Switch->"facial expression x-axes"*)
{{f,1,"Facial Expression y-axes"},0.8,2},(*Switch->"facial Expression y-axes"*)
{{g,0.1,"Eye Size x-axes"},0.02,0.25},(*Switch->"eye size x-axes*)
{{h,0.1,"Eye Size y-axes"},0.02,0.25},(*Switch->"eye size y-axes*)
{{p,0,"Lips expression"},0,20},(*Switch->"lips expression"*)
{{o,False,"Check for Axes"},{True,False},ControlType->Checkbox},AutorunSequencing->All](*Axes on and off*)

Section 3. Conclusion and Future Work

3.1 Summary

Most of time I draw the faces and make emotional face moving as each variables move. This is becuase I had to change range of the vatiances many times whenever I made new variables. Although I use manipulating for my mini-project, it is still amazing for me, I could easily change many variables at the same time, so the all of each pieces of shapes can move at the same time. Actually manipulating does make this very emotional. When I click “auto run” it was tons of face will comes out. The hardest part was making switches. I was very confused to make switch before but I learn a lot during this final project. however once we know how to use this,  it is very useful and It will make this project much neat. Thus anyone who is looking my project can easily change this emotion with these switches. Addition, the switch can be the inside of the switch which means, the shape of sunglass switch can be on and off mode when the “Smile” switch button on. I think, we can create many different type of switch function.

3.2 Discussion

Overall , most of time I worked with face and its changing emotion. The hardest part was that I needed to change range of each variables when I put everything in one manipulate. This was because, every time I added one thing in manipulating, the range had to be changed. For example, the eyes was totally out of the faces because of the range of face and eyes are not matching. I changed many times and I got right size at the last moment. I thought I learn a lot about manipulating but, I learn again how to putting axes disappear and make another button to show axes whenever I want. It was very impressive to move all pieces on the one face. I thought there is a limited to make this changing. However, it never done, I could change eye, mouth, outer inner eye brows, and facial expression and even more. The facial expression was the funniest part to make this face funny. 
 Second hardest part was the “switch”. I saw switch couple of times before, but I never try to create one. It took me long time to create this, because each smile, sad, angry face code has to be organized and I need to write smile, sad, angry in order. 
While I draw tear and glasses, I never know there is a “polygon” to create this. Actually I can draw many types of shape with polygon once you know how to use. I never thought, I can draw actual picture like I draw, but I found it there are lots of method to draw. There is one to remember when you use the polygon. it has to be right point with right order. I figure how it order, and never draw, if there is any little mistake. Wolfram search was helpful  when I draw sunglasses.

3.3 Future Work

If I had more time to do this project, I want to do lots of thing to add on this project. First, I want to create more emotional faces on the Switch part. Moreover, I want to make tear and glasses or even more manipulate inside of the "Switch" which I wasn’t able to do. Second I wanted to create nice hair on this shape. However, it was not so easy and could not figure it on time.

Section 4. References

Wolfram Mathematica Website.
Google
Youtube
Christopher Hanusa
Jin Shen Yap
Brian Liew
Diana Echeverri