Functions and Recursion – 55 course pointsThis assignment consists of two parts. First, write a library of static methods thatperforms geometric transforms on polygons. Next, write a program that plotsa Sierpinski triangle.ProgrammingWrite 2 programs and submit on Sakai.We provide a zip containing PolygonTransform.java, and Sierpinski.java. For eachproblem update and submit the corresponding file.DO NOT use System.exit()DO NOT add any import statementsDO NOT add the project or package statementsDO NOT change the class nameDO NOT change the headers of ANY of the given methodsDO NOT add any new class fieldsONLY print the result as specified by the example for each problem.DO NOT print other messages, follow the examples for each problem.USE StdIn, StdOut, and StdDraw libraries.1. Polygon transform (25 points). Write a library of static methods that performsvarious geometric transforms on polygons. Mathematically, a polygon is definedby its sequence of vertices (x0, y 0), (x 1, y 1), (x 2, y 2), …. In Java, we willrepresent a polygon by storing the x– and y-coordinates of the vertices in twoparallel arrays x[] and y[].Three useful geometric transforms are scale, translate and rotate.Scale the coordinates of each vertex (x i, y i) by a factor α.x‘i = α xiy‘i = α yiTranslate each vertex (x i, y i) by a given offset (dx, dy).x‘i = xi + dxy‘i = yi + dyRotate each vertex (x i, y i) by θ degrees countercldata留学生作业代写、java程序语言作业调试、代写Java课程设计作业 帮做C/C++编程|代写Python编程ockwise, around the origin.x‘i = xi cos θ – yi sin θy‘i = yi cos θ + xi sin θWrite a two-dimensional transformation library by implementing the following API:3. Sierpinski (30 points). The Sierpinski triangle is an example of a fractal patternlike the H-tree pattern from Section 2.3 of the textbook.The Polish mathematician Wacław Sierpiński described the pattern in 1915, but ithas appeared in Italian art since the 13th century. Though the Sierpinski trianglelooks complex, it can be generated with a short recursive function. Your maintask is to write a recursive function sierpinski() that plots a Sierpinski triangle oforder n to standard drawing. Think recursively: sierpinski() should draw one filledequilateral triangle (pointed downwards) and then call itself recursively threetimes (with an appropriate stopping condition). It should draw 1 filled triangle for n= 1; 4 filled triangles for n = 2; and 13 filled triangles for n = 3; and so forth.API specification. When writing your program, exercise modular design by organizing itinto four functions, as specified in the following API:Restrictions: You may not change either the scale or size of the drawing window.Before submission1. Collaboration policy. Read our collaboration policy here.2. Update @author. Update the @author tag of the files with your name, email andnetid.3. Submitting the assignment. Submit PolygonTransform.java, and Sierpinski.javaseparately on Sakai.转自:http://www.6daixie.com/contents/9/5217.html
讲解:data、java、JavaC/C++|Python
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...