Betsy Ross Problem
Matlab学习中的betsy ross 问题。用matlab函数画1777年的美国国旗。

五角星绘制部分是自己想出来的方法去画上的。具体代码参考如下。
先是绘制矩形的函数
function DrawRect(a,b,L,W,c)
%Adda a Rectangle to the current window .Assumes hold is on.
%The Rectangle has vertices (a,b),(a+L,b),(a,b+W),(a+L,b+W)
%The c is color which is in the form of 'rgb vector' or one of the built-in
%clolors such as 'r','g','y','b'
x=[a,a+L,a+L,a];
y=[b,b,b+W,b+W];
fill(x,y,c);
然后是绘制五角星的代码
function DrawStar(x1,y1,dr,c)
%the center of the five-stars is at (x1,y1)
%the radius of five-stars
%the color of the five-star
dtheta=*pi/;
hold on
axis equal off
j=:;
%外部五个点
x=x1+dr*cos(j*dtheta+pi/);
y=y1+dr*sin(j*dtheta+pi/);
%内部五个点
xl=x1+dr*cos(j*dtheta+*pi/)/;
yl=y1+dr*sin(j*dtheta+*pi/)/;
%Seperately take the ten points into vector
X=[x(),xl(),x(),xl(),x(),xl(),x(),xl(),x(),xl()];
Y=[y(),yl(),y(),yl(),y(),yl(),y(),yl(),y(),yl()];
%then draw it.
fill(X,Y,c);
然后调用上面的两个函数,绘制整个旗帜
function DrawFlag(a,b,L1,W1,L2,r1,r2)
%Adds a -star,-stripe Colonial flag to the current
%Figure window.Assumes hold id on
%The flag is L1-by-W1 with lower left corner at(a,b).
%The length fo the blue area is L2.The ring of stars has radius r1 and its
%center is the center of the blue area
%the radius of the individual stars is r2
clc
close all
figure
hold on
s=W1/;
axis equal off
for k=:
%Draw the kth stripe
bk=b+(k-)*s;
if rem(k,)==&&k<=
DrawRect(a,bk,L1,s,'r');
elseif rem(k,)==&&k<=
DrawRect(a,bk,L1,s,'w');
elseif rem(k,)==&&k>=
DrawRect(a+L2,bk,L1-L2,s,'r');
else DrawRect(a+L2,bk,L1-L2,s,'w');
end
end
DrawRect(a,b+*s,L2,*s,'b');
%draw star
theta=*pi/;
xc=(a+L2)/;
yc=9.5*s;
for k=:
xr=xc+r1*cos(k*theta+pi/);
yr=yc+r1*sin(k*theta+pi/);
DrawStar(xr,yr,r2,'w');
end
hold off
Betsy Ross Problem的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
随机推荐
- Python中fnmatch模块的使用
fnmatch()函数匹配能力介于简单的字符串方法和强大的正则表达式之间,如果在数据处理操作中只需要简单的通配符就能完成的时候,这通常是一个比较合理的方案.此模块的主要作用是文件名称的匹配,并且匹配的 ...
- Python 标准库中的装饰器
题目描述 1.简单举例 Python 标准库中的装饰器 2.说说你用过的 Python 标准库中的装饰器 1. 首先,我们比较熟悉,也是比较常用的 Python 标准库提供的装饰器有:property ...
- C++ 类的定义与实现
摘自这篇博客https://blog.csdn.net/xulingxin/article/details/81335030 一."类" 的介绍 在C++中, 用 &q ...
- Notes of Scrum Meeting(2014/11/2)
Notes of Scrum Meeting (2014/11/2) 软件工程项目组Sevens开始项目之后的第一次Scrum Meeting报告 会议时间:2014年11月2日 20:00—20: ...
- Teamproject Week7 --Scrum Meeting #1 2014.10.28
这是团队的第一次会议,具体议题如下: 1)我们明确了团队成员的职责所需: PM职责:根据项目范围.质量.时间与成本的综合因素的考虑,进行项目的总体规划与阶段计划. 控制项目组各成员的工作进度,即时了 ...
- No.1010_第七次团队会议
渺茫的前景 今天大家都很失望,一来昨天的问题还是继续存在着,仍然没有完成.二来,我们看了一下其余几个组的界面,对自己有些难过. 我们组确实存在人手少的问题,这几天我还因为挑战杯的事情缺席了两天,感觉内 ...
- 【Alpha】阶段第七次Scrum Meeting
[Alpha]阶段第七次Scrum Meeting 工作情况 团队成员 今日已完成任务 明日待完成任务 刘峻辰 增加上课信息接口 编写按学院搜索课程接口 赵智源 构建后测试点测试框架 构建前测试点测试 ...
- Maven教程--02设置Maven本地仓库|查看Maven中央仓库
一:设置Maven本地仓库 Maven默认仓库的路径:~\.m2\repository,~表示我的个人文档:例如:C:\Users\Edward\.m2\repository:如下图: Maven的配 ...
- 超实用 2 ArrayList链表之 员工工资管理系统
package ArrayList的小程序; import java.io.*; import java.util.*; public class kkk { /** * 作者:Mr.fan * 功能 ...
- mvc 页面方法学习-RenderBody方法
教程地址:https://docs.microsoft.com/zh-cn/aspnet/mvc/overview/getting-started/introduction/adding-a-view