明确概念
弧度:弧长等于半径的弧为1,float angle = radians(N)
rectMode(CENTER):默认绘制长方形是以左上角为起始点,rectMode(CENTER) interprets the first two parameters of rect() as the shape's center point, while the third and fourth parameters are its width and height.
pushMatrix/popMatrix:当需要修改坐标系系统时使用,The pushMatrix() function saves the current coordinate system to the stack and popMatrix() restores the prior coordinate system.
translate:修改坐标系圆点的位置,translate(x, y, z)
rotate:The coordinates are always rotated around their relative position to the origin(origin即坐标系的圆点), rotate(radians)
sin/cos: amplitude * sin/cos(angle),angle确定数值,amplitude确定数值在y坐标上的表现
beginShape()/endShape(): 用于绘制复杂图形的开始和结束,vertex(x, y)用于确定图形中的各个点
明确功能
1.多个长方形在空间中旋转
功能设计
类:Mover
属性:location,aVelocity,aAcceleration,size
方法:move(),display()
伪代码
setup(){
}
draw(){
mover.move()
mover.display()
}
class Mover{
定义属性
Mover(){}
定义方法
}
正式代码
见:
Processing/Oscilation at master · JoeyQiang/Processing · GitHub
代码优化
1.沿着速度方向转
网友评论