use p1 to p4 instead of a matrix

This commit is contained in:
Shuo Feng 2024-02-20 22:32:55 -05:00
parent f624514714
commit 295bdc0c89
Signed by: sfeng
GPG key ID: 1E83AE6CD1C037B1
2 changed files with 10 additions and 5 deletions

View file

@ -49,14 +49,15 @@ private:
class Rectangle : public Geometry {
public:
Rectangle(float ka, float kd, float ks, const Vector3f &ca, const Vector3f cd,
const Vector3f &cs, float pc, const Matrix<float, 3, 4> &corners)
: Geometry(Type::RECTANGLE, ka, kd, ks, ca, cd, cs, pc),
corners(corners) {}
const Vector3f &cs, float pc, const Vector3f &p1,
const Vector3f &p2, const Vector3f &p3, const Vector3f &p4)
: Geometry(Type::RECTANGLE, ka, kd, ks, ca, cd, cs, pc), p1(p1), p2(p2),
p3(p3), p4(p4) {}
bool intersect(const Ray &) const override;
private:
Matrix<float, 3, 4> corners;
Vector3f p1, p2, p3, p4;
};
#endif // !GEOMETRY_H_

View file

@ -95,8 +95,12 @@ Rectangle *Parser::getRectangle(const nlohmann::json &j, float ka, float kd,
const Vector3f &cd, const Vector3f &cs,
float pc) {
Matrix<float, 3, 4> corners = getCorners(j);
Vector3f p1 = getVector3f(j["p1"]);
Vector3f p2 = getVector3f(j["p2"]);
Vector3f p3 = getVector3f(j["p3"]);
Vector3f p4 = getVector3f(j["p4"]);
return new Rectangle(ka, kd, ks, ca, cd, cs, pc, corners);
return new Rectangle(ka, kd, ks, ca, cd, cs, pc, p1, p2, p3, p4);
}
Light *Parser::getLight(const nlohmann::json &j) {