람다에 대해 더 잘 이해할 수 있도록 저는 회전하고 쿼드를 변형시키는이 짧은 스 니펫을 썼습니다. 이제 아래의 3 단계를 하나의 라이너 람다 (아마도 map()과 함께)로 대체하려고합니다.람다를 도와주세요
메신저 vector class을 사용하고 있지만 잘하면이 기능은 분명합니다.
self.orientation = vector(1,0)
self.orientation.rotate(90.0)
#the four corners of a quad
points = (vector(-1,-1),vector(1,-1),vector(1,1),vector(-1,1))
print points
#apply rotation to points according to orientation
rot_points = []
for i in points:
rot_points.append(i.rotated(self.orientation.get_angle()))
print rot_points
#transform the point according to world position and scale
real_points = []
for i in rot_points:
real_points.append(self.pos+i*self.scale)
print real_points
return real_points
한 게시물에 너무 많은 파이썬이 있습니다! –
그래서 엄밀히 말하면 생성자가 목록 작성이 아닌 선호됩니다. – zweiterlinde
zweiterlinde : 그래서 생성자 표현> 목록 내포> 람다? – Mizipzor