
// QuadraticInfo.cpp - interface for class to compute facet angle from quadratic Bezier segment

#ifndef __QuadraticInfo_hpp__
#define __QuadraticInfo_hpp__

#include <Cg/vector/xyzw.hpp>
#include <Cg/double.hpp>
#include <Cg/vector.hpp>
#include <Cg/matrix.hpp>

using namespace Cg;

class QuadraticInfo {
    float3 cp[3];

    double curvature;

    double2 A;
    double2 B;

    double limit_angle;
    double limit_angle_neg;
    double2 limit_direction;

    double2 computeQuadraticFacetTPair(float t, float theta, float max_turning_angle_delta, int step_mode);

    double biasQuadraticFacetAngleAndFindT(float t, float t_direction, double theta, float bias);
    double findCorrectT(float angle, float orig_t,  float t_direction);
    double fromBiasedAngleFindT(float theta, float t, float t_direction, float bias);
    double2 computeQuadraticFacetTPair(float t, float theta, const double2 gradient, float max_turning_angle_delta, int step_mode);

    // ctor helpers
    void computeLimitAngleAndDirection();
    void computeMonomialCoeffs();
    void computeCurvatureState();

public:
    QuadraticInfo(const float3 cps[3]);
    float computeFacetAngle(float t, float max_turning_angle_delta, int step_mode);
};

#endif // __QuadraticInfo_hpp__
