⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 geom_util.cpp

📁 The goal of this project is to explore the idea of point-based radiosity, which is a shooting radio
💻 CPP
字号:
/*+-------------------------------------------------------------------
  Ben Landon
  CSCI E-235

  geom_util.cpp 

*/

#include <assert.h>
#include "geom_util.hpp"

void get_barycentric_parameters_2D (float x,  float y,
				    float x0, float y0, 
				    float x1, float y1, 
				    float x2, float y2,
				    float& t1, float& t2)
{
    float v11 = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);
    float v22 = (x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0);

    float v12 = (x1 - x0) * (x2 - x0) + (y1 - y0) * (y2 - y0);
    float v21=  v12;

    float vx1 = (x - x0) * (x1 - x0) + (y - y0) * (y1 - y0);
    float vx2 = (x - x0) * (x2 - x0) + (y - y0) * (y2 - y0);

    float denom = v11 * v22 - v21 * v12;
    
    float t1_num = vx1 * v22 - vx2 * v12;
    float t2_num = v11 * vx2 - v12 * vx1;

    if (denom == 0)
    {
	assert(false);
	return; // not sure what to do here
    }

    t1 = t1_num / denom;
    t2 = t2_num / denom;
    
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -