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
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。