明確概念
弧度:弧長(zhǎng)等于半徑的弧為1,float angle = radians(N)
rectMode(CENTER):默認(rèn)繪制長(zhǎng)方形是以左上角為起始點(diǎn),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:當(dāng)需要修改坐標(biāo)系系統(tǒng)時(shí)使用,The pushMatrix() function saves the current coordinate system to the stack and popMatrix() restores the prior coordinate system.
translate:修改坐標(biāo)系圓點(diǎn)的位置,translate(x, y, z)
rotate:The coordinates are always rotated around their relative position to the origin(origin即坐標(biāo)系的圓點(diǎn)), rotate(radians)
sin/cos: amplitude * sin/cos(angle),angle確定數(shù)值,amplitude確定數(shù)值在y坐標(biāo)上的表現(xiàn)
beginShape()/endShape(): 用于繪制復(fù)雜圖形的開(kāi)始和結(jié)束,vertex(x, y)用于確定圖形中的各個(gè)點(diǎn)
明確功能
1.多個(gè)長(zhǎng)方形在空間中旋轉(zhuǎn)
功能設(shè)計(jì)
類:Mover
屬性:location,aVelocity,aAcceleration,size
方法:move(),display()
偽代碼
setup(){
}
draw(){
? ? mover.move()
? ? mover.display()
}
class Mover{
? ? 定義屬性
? ? Mover(){}
????定義方法
}
正式代碼
見(jiàn):
Processing/Oscilation at master · JoeyQiang/Processing · GitHub
代碼優(yōu)化
1.沿著速度方向轉(zhuǎn)