Example #1
0
std::vector<MatrixXd>
rasterize_2(const Density_2 &pl,
	    const MatrixXd &X,
	    const VectorXd &w,
	    const MatrixXd &colors,
	    double x0, double y0, double x1, double y1, // bounding box
	    int ww, int hh)
{
  check_points_and_weights(X, w);
  if (colors.rows() != X.rows())
    {
      PyErr_SetString(PyExc_TypeError,
		      "Color array should be Nxk, where N is "
		      "the number of points and k arbitrary");
      throw py::error_already_set();
    }
  typedef VectorXd Color;
  std::vector<Color> colorv (colors.rows());
  for (int i = 0; i < colors.rows(); ++i)
    colorv[i] = colors.row(i);

  // FIXME: avoid matrix copies
  int nchannels = colors.cols();
  std::vector<MatrixXd> channels(nchannels, MatrixXd::Zero(ww,hh));
  MA::draw_laguerre_diagram(pl._t, pl._functions, X, w, colorv,
			    x0, y0, x1, y1, ww, hh,
			    [&](int i, int j, const Color &col)
			    {
			      for (int k = 0; k < nchannels; ++k)
				channels[k](i,j) += col[k];
			    });

  return channels;
}
Example #2
0
	void LightPoint::update_radius() {
		XMVECTOR v = colorv();
		float r = XMVectorGetX(v);
		float g = XMVectorGetY(v);
		float b = XMVectorGetZ(v);
		float max = std::fmaxf(std::fmaxf(r, g), b);
		m_radius = (-m_linear +
					std::sqrtf(m_linear * m_linear -
							   4 * m_quadratic * (m_constant - 256.0f * intensity() * max)))
			/ (2 * m_quadratic);
	}
Example #3
0
	void Light::set_intensity(float i) {
		XMVECTOR v = colorv();
		XMVectorSetW(v, i);
		set_color(v);
	}
Example #4
0
	FLOAT Light::intensity() const {
		XMVECTOR v = colorv();
		return XMVectorGetW(v);
	}