1 #ifndef gra_WatchBall_H__
2 #define gra_WatchBall_H__
7 #include "../geo/Vectors.h"
8 #include "../math/LinearTransformations.h"
9 #include "../oo/ObjBase.h"
24 typedef std::vector<Camera<Pixel> >
Cameras;
35 cameras_ = b.cameras_;
81 return self->cameras_.size();
88 return self->cameras_;
95 return self()->cameras_;
102 self()->cameras_ = c;
132 return self->offset_;
139 return self()->offset_;
146 self()->offset_ = ofs;
157 for (
size_t i = 0, I =
cameraSize(); i < I; ++i) {
158 if (
camera(i).inside(p2)) {
159 sum = sum +
camera(i).color(p2);
163 return (ct > 0 ? sum / ct : sum);
172 radius = std::max(radius, 0.5);
173 size_t height = std::max<size_t>(1, 2.0 * radius);
174 size_t width = 2.0*
PI * radius;
176 for (
size_t i = 0; i < height; ++i) {
177 for (
size_t j = 0; j < width; ++j) {
178 double theta = (1.0 * j / width - 0.5) * 2 *
PI;
179 double phi = asin(-(1.0 * i / height - 0.5) * 2.0);
181 sin(theta) * cos(phi),
183 -cos(theta) * cos(phi)
201 bool write(FILE* f,
bool bin,
unsigned int fg)
const {
209 bool read(FILE* f,
bool bin,
unsigned int fg) {
239 static char const* ptr =
typeid(*this).name();
248 return std::string(
ctype());
254 #endif // gra_WatchBall_H__
WatchBall & referenceFrom(WatchBall const &b)
reference
Vector3D< double > & offset()
取得offset (non-constant reference)
bool write(FILE *f, bool bin, unsigned int fg) const
將資料寫入檔案
Vector3D< double > const & offset(Vector3D< double > const &ofs)
設定offset
char const * ctype() const
回傳class的type
Cameras const & cameras() const
取得 cameras
ObjBase * create() const
new一個自己
Pixel pixel(size_t y, size_t x) const
取得 (y, x) 的pixel
Camera< Pixel > const & camera(size_t i, Camera< Pixel > const &c)
設定第i個camera
一切物件的Base, 並要求每個物件都要有read, write, create, ... 等功能
WatchBall & copyFrom(WatchBall const &b)
copy data
多個camera, 一個offset, 一個rotation
ObjBase * copyFrom(ObjBase const *b)
複製資料
bool read(FILE *f, bool bin, unsigned int fg)
將資料讀入
Pixel color(Vector3D< double > p) const
取得底片color
Bitmap< Pixel > expand(double radius) const
輸出展開圖
Camera< Pixel > const & camera(size_t i) const
取得第i個camera
static const double PI
圓周率...
Camera< Pixel > & camera(size_t i)
取得第i個camera (non-constant reference)
size_t cameraSize() const
取得有幾個camera
WatchBall(WatchBall const &b)
copy constructor
std::string type() const
回傳class的type
Vector3D< double > const & offset() const
取得offset
WatchBall & operator=(WatchBall const &b)
same as copyFrom(b)
Cameras const & cameras(Cameras const &c)
設定 camera
Cameras & camerasGet()
取得 cameras (non-constant)
std::vector< Camera< Pixel > > Cameras