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 标准库中的装饰器
题目描述 1.简单举例 Python 标准库中的装饰器 2.说说你用过的 Python 标准库中的装饰器 1. 首先,我们比较熟悉,也是比较常用的 Python 标准库提供的装饰器有:property ...
- markdown语法示例
现在是我在学习Markdown时做的笔记.学完这些Markdown的基本使用已经不成问题. 1. 标题设置(让字体变大,和word的标题意思一样)在Markdown当中设置标题,有两种方式:第一种:通 ...
- Daily Scrum 11.14
姓名 今日任务 黄新越 按照热度排序->产生柱状图 刘垚鹏 总体代码架构整合 王骜 总体代码架构整合 林旭鹏 优化整体UI布局 安康 优化整体UI布局 黄伟龙 预先合作编写测试用例 马佐霖 预先 ...
- java的内存管理机制
1.内存区域的分类 栈内存:基本类型变量和对象的引用,优势在于存取速度快 堆内存:new创建的对象和数组以及对象的实例化变量,优势在于动态分配内存,但是存取速度相对较慢 2.不同类型的内存分配 (1) ...
- SpringMVC运行原理浅析
SpringMVC是主流的J2EEWEB层框架,SpringMVC是Sping家族中一个重要的产品.下面给出SpringMVC的运行原理.springmvc和spring无需通过中间层进行整合,spr ...
- Beta冲刺(5/7)
队名:天机组 组员1友林 228(组长) 今日完成:修改代码 明天计划:封装代码 剩余任务:优化网络通讯机制 主要困难:暂无 收获及疑问:暂无 组员2方宜 225 今日完成:优化了ui界面 明天计划: ...
- [BUAA_SE_2017]提问回顾
提问回顾 学期初疑问回答 学期初疑问博客 教材中说,PM在衡量需求时需要方方面面的能力与研究.可是,当下许多互联网IT公司只承担外包业务,即客户给什么需求就实现什么需求,甚至可能不要求其它先进的功能. ...
- Beta阶段DAY2
一.提供当天站立式会议照片一张 二.每个人的工作 1.讨论项目每个成员的昨天进展 刘阳航:删除多余按钮,调整界面. 林庭亦:删除麻烦的颜色设置. 郑子熙:添加新增按钮. 陈文俊:重新规划面板及功能. ...
- Qt Lighthouse学习(二),就是QPA(Qt Platform Abstraction) 项目的名字
上一次关注Qt Lighthouse是在6月初,可是现在都8月底了.时间真快... Lighthouse 是 QPA(Qt Platform Abstraction) 项目的名字,它使得将Qt移植到新 ...
- find K maximum value from an unsorted array(implement min heap)
Maintain a min-heap with size = k, to collect the result. //Find K minimum values from an unsorted a ...