1 / 60

Transforming Math into Pictures.

113 views
Category: Travel / Places
Description
Transforming Math into Pictures John Peterson Yale College http://haskell.org/edsl Welcome! You'll have to know a couple of things for this session: Math: facilitates on a plane, capacities, diagrams PCs: utilizing Windows and altering content records
Transcripts
Slide 1

Transforming Math into Pictures John Peterson Yale University http://haskell.org/edsl

Slide 2

Welcome! Youâll need to know a couple of things for this session: Math: facilitates on a plane, capacities, diagrams Computers: utilizing Windows and altering content documents If you donât have much involvement with these things please combine up with a more experienced understudy!

Slide 3

Writing so as to make Pictures We will make pictures PC programs that transform essential science into pictures. Our objective is for every understudy (or group) to make three pictures. We will put these on a page for anyone passing by to view when this session is over. If it\'s not too much trouble make inquiries whenever!

Slide 4

Using Pan# As I talk I will demonstrate to you test picture programs. Iâd like you to run these yourself as Iâm talking so you wonât nod off. What\'s more, you can likewise change these projects a tiny bit to see what happens or fiddle with the controls if youâre exhausted. Letâs perceive how to run and alter a project.

Slide 5

Displaying a Picture All you have to do is open (snap on) a .container record to see the photo it portrays. If it\'s not too much trouble look in the organizer âpicturesâ on your desktop and snap on the photo named â 01-welcome â Note that there are controls which administer the photo. Play with these a bit. Presently spare the photo on your circle with the âsave asâ choice on the File menu.

Slide 6

Writing a Program Now, letâs compose a system to make a photo. Utilize the content tool and compose the accompanying: picture (r @ a) = if even(r/10) then white else green Save this in the document test.pan

Slide 7

Running a Program To run a project, open (double tap) the test.pan record. What happens when you run this system? On the off chance that you commit any errors entering the system youâll get a message when you open it. You ought to do a reversal to the manager to alter the issue, close the window with the message, and attempt once more.

Slide 8

Demos When I have a picture on a slide or some code that has a document name under it you will find that record in the âpicturesâ catalog. You can run the demo while Iâm conversing with see what happens 02-star.pan

Slide 9

Extending a Language You definitely know two dialects: English and Mathematics. We need to have a dialect that incorporates Mathematics and pictures as well. Letâs consider how we augment (add new words to) English to perceive how we can develop Mathematics.

Slide 10

Whatâs this mean? âFred gave me his zaxâ

Slide 11

Whatâs this mean? âFred gave me his zaxâ Iâm puzzled as well! So what would it be advisable for us to do?

Slide 12

Looking up another wordâ¦ âFred gave me his zaxâ From a lexicon: n. an instrument like an ax, utilized for cutting and dressing material slates.

Slide 13

Building Language Aha! We can make a dialect greater by offering definitions to new words. The new word is a name for some new idea. Mathematicians use definitions to make new words (names) constantly. These definitions express new words regarding ones you definitely know.

Slide 14

Computer Languages A scripting language is much the same as some other dialect aside from a PC realizes what youâre saying. PCs are extremely particular! On the off chance that you record something thatâs wrong (awful spelling, lost accentuation, complete rubbish) it will gripe.

Slide 15

Functions One all the more thing: definitions regularly are parameterized . That is, they contain names that are âfilled inâ when the definition is utilized. Such a definition is a capacity . Definition: the midpoint of a line between focuses An and B is a point on hold, C, such that the separation from A to C is the same as the separation from B to C.

Slide 16

Notation The PC needs you to record definitions in an exceptionally specific manner: name parameters = body pi = 3.14159 addition x = x + 1 plusTwo x = (increase x) midpoint a b = (a + b)/2 We donât use bracket for capacity calling; f x rather than f(x)

Slide 17

Types and Logic There are a considerable measure of approaches to âmess upâ in a dialect: Typing Mistakes: Fred ga?ve mehis z.ax Illogical sentences: âHave a zax day!â Since zax is a thing this doesnât bode well. Mathematicians use rationale to tell whether a sentence is garbage or OK. Sorts (like ânounâ) depict an arrangement of articles. Iâm beyond any doubt the PC will once in a while grumble about the language structure or sorts in your projects. Rationale will assist us with comprehension things better.

Slide 18

About Pan# A system is similar to a word reference. It is an arrangement of definitions, every beginning in the furthest left segment, in any request you need. There is an implicit vocabulary that you use to fabricate new definitions A project must characterize the name âpictureâ so that when you run it the viewer recognizes what you need to see.

Slide 19

Everything is a Function Functions can be utilized to speak to a wide range of things. Weâre going to utilize capacities to speak to pictures. Each capacity has an area (sorts of things that âgo inâ to the capacity) and a reach (sorts of things that âcome outâ of the capacity. For pictures, our space is (a bit of) the direction plane and our reach is hues. That is, a photo is something that lets you know âif you look here, youâll see this colorâ

Slide 20

Coordinates A direction is something that âpoints toâ a spot on the plane. A direction is similar to a house address - it lets you know how to discover a spot. Coordinate frameworks have a birthplace - a point in the focal point of the plane from which different focuses are found.

Slide 21

Rectangular Coordinates Rectangular directions are composed as (x,y), where x is the point\'s projection onto the x pivot and y is the point\'s projection onto the y hub. y P (4,2) 2 4 x

Slide 22

Polar Coordinates There is another approach to express arranges on the plane: polar directions. These utilization a separation, d, and a heading, edge, to find a point from the inception. d edge We compose this as (d @ point) in our dialect. The point is measured in radians - these are kind of like degrees aside from they go from 0 to 2 p ( or - p to p)

Slide 23

Some Questions If you are remaining at the coordinate\'s beginning framework and somebody instructed you to go to (x,y) how might you go there? Imagine a scenario in which they instructed you to go to (d @ a.

Slide 24

Coordinates in Pan# The typical direction framework in Pan# utilizes âpixelsâ (those little dabs that make up your showcase) to quantify separation. The cause is in the focal point of the showcase window. You can see these two direction frameworks in real life in your demos: 03-rectangular.pan 04-polar.pan

Slide 25

Colors We portray hues utilizing 3 numbers, each somewhere around 0 and 1 Amount of Red Amount of Green Amount of Blue Example: Yellow = Red + Green rgb 1 0 Play with hues a moment utilizing 05-showColor.pan to see what a shading resembles

Slide 26

A Picture! We can characterize a straightforward picture like this: picture(d @ a) = if d < 50 then dark else white What will this photo resemble? The âif - then - elseâ permits you to pick one of two hues

Slide 27

An Interactive Picture! r <- slider âSelect râ (0,100) 50 picture(d @ a) = if d < r then dark else white The âsliderâ permits you to perceive how the photo changes as ârâ changes. 06-icircle.pan

Slide 28

Regions An area is a capacity that lets you know whether a point is in the district or not. So the circle in the last sample is a locale. You could compose this as circ (d @ a) = d < r picture p = if circ p then dark else white Weâll separate the project into areas and a âregion paintingâ capacity.

Slide 29

Regions A locale is a capacity that lets you know whether a point is in the area or not. So the circle in the last illustration is an area. You could compose this as circ (d @ a) = d < r picture p = if circ p then dark else white Weâll separate the project into locales and a âregion paintingâ capacity. A district

Slide 30

Regions An area is a capacity that lets you know whether a point is in the locale or not. So the circle in the last sample is a locale. You could compose this as circ (d @ a) = d < r picture p = if circ p then dark else white Weâll separate the system into districts and a âregion paintingâ capacity. Painting the locale

Slide 31

Striping We need to draw stripes! Letâs control Distance between stripes (pixels) Width of the stripe (portion) We require an uncommon capacity to do this: floor(x) is the best whole number less that x. floor (2.34) = 2 story (9.99) = 9 story (- 0.1) = ???

Slide 32

Striping We figure the partial piece of x/width. Where is this 0? frac x = x - floor x stripes width size x = frac ((x + width/2)/width) < size p <- slider "Distance between stripes" (0, 100) 20 w <- slider "Stripe width (fraction)" (0,1) 0.5 picture (x,y) = if stripes p w x then dark else white 07-stripes.pan

Slide 33

Combining Regions We can make works that paste locales together in diverse ways. How might you make a capacity that structures the union of two areas?

Slide 34

Region Union A point âpâ is in the union of r1 and r2 on the off chance that it is in r1 or r2. orRegion r1 r2 = \p - > r1 p || r2 p Donât stress if this appears to be difficult to take after! We wonât need to compose capacities to do things with districts - they are as of now characterized for you. this is âorâ area looks here

Slide 35

Region Functions Here a

Recommended
View more...