先上图:
初始参数(设置):
//输入初始参数:
double arc1 = (7.0 / 16.0)*Pild;
line01light02(hdc, arc1, 19, 300, 410); //参数说明: hdc绘图板,入射角arc1= 7/16PI, x1=300,y1=410为入射光线初始坐标
![](https://box.kancloud.cn/6fe1df34ada2d2e969c3db6172aa56a2_854x599.png)
核心代码:
void line01light02(HDC hdc, double arc1, unsigned long lineLen, double X01, double Y01) {
//
double arc1arg02 = regularAngle(arc1);
double X001 = X01; double Y001 = Y01;
double X002 = X001; double Y002 = Y001;
line2normal(hdc, arc1, X001, Y001, RGB(0, 200, 200), 10);
cout << "[arc1arg01:" << arc1 << "]-";
cout << "[arc1arg02:" << arc1 << "]; ";
unsigned long itime = 0;
double old1X001 = X001; double old1Y001 = Y001;
double mid01X01 = X001; double mid01Y01 = Y001;
double arc01normal01origin001;
double arc1normal01;
double fanshe01Arc01;
double reflecteAng01;
double Xorigin01; double Yorigin01;
//
//循环光走(光线前进-简称光进)并反射等
//do {
//
lable110start:
if (lineLen < 1) { return; }
lable120:
itime = 1;
cout << "[itime:" << itime << "]_";
lable220:
//开始算 反射角,并 (继续)光进
Xorigin01 = cos(arc1arg02)*(double)itime; Yorigin01 = sin(arc1arg02)*(double)itime;
lable230:
X001 = Xorigin01 + old1X001; Y001 = Yorigin01 + old1Y001;
setpixe02l(hdc, X001, Y001, RGB(255, 25, 0));// , 255, 0));//绘图封装,封装都是有目的 的;没有目的 的“瞎封装”…会从我的小组被开除--Terry.
lable510:
//判断并(光线)步进:
//if先判断是否在月亮形状里: (isInC2littlecircle && !isInC1BigCircle)
if (isInMoon(X001, Y001)) {//if110
itime = 1;
lineLen--;
old1X001 = X001; old1Y001 = Y001;
itime++;
goto lable220;
}//if110
//与小圆的上弧相交,else if下面判断:是否出了月亮,即出了小圆,(当然)也出了大圆
else if ( isInMoon(old1X001,old1Y001) && (!isInC2littlecircle && !isInC1BigCircle) ) {
double arc01normal01origin01 = atan( (400-X001)/(Y001-400) );
arc1normal01 = Pild / 2.0 + arc01normal01origin01;
line2normal(hdc, arc1normal01, old1X001, old1Y001, RGB(0, 100, 0), 5); //暗绿色法线
fanshe01Arc01 = arc1arg02 - 2 * arc1normal01;
reflecteAng01=Pild - fanshe01Arc01;
line2normal(hdc, reflecteAng01, old1X001, old1Y001, RGB(0, 255, 0), 6);//亮绿色反射线
arc1arg02 = reflecteAng01;
cout << "[01-arc1normal01:" << arc1normal01 << "]";
// system("pause");
goto lable220;
}//if110elseif120
//elseif下面判断:是否出了月亮,既然在小圆内,(但)仍然在大圆内(两圆相交处
else if ( isInMoon(old1X001,old1Y001) && (isInC2littlecircle && isInC1BigCircle) ) {
arc01normal01origin001 = atan((400 - X001 / (Y001 - 0) ) );
arc1normal01 = (Pild / 2.0 - arc01normal01origin001);
line2normal(hdc, arc1normal01, old1X001, old1Y001, RGB(0, 0, 100), 19); //暗蓝法线
fanshe01Arc01 = Pild + arc1arg02 - 2 * arc1normal01;
reflecteAng01 = fanshe01Arc01;
arc1arg02 = reflecteAng01;
line2normal(hdc, reflecteAng01, old1X001,old1Y001, RGB(255, 200, 0), 5);
cout << "[arc1normal01:" << arc1normal01 << "]";
system("pause");
goto lable220;
}//if110elseif130
//不在小圆内,但在大圆内(第4块--特殊区域
else if (!isInC2littlecircle&&isInC1BigCircle)
{
lable910:
//迭代找第1次,第一个弧的交点,即不在inInMoon内的第一个点
mid01X01 = (X001 + old1X001) / 2;
mid01Y01 = (Y001 + old1Y001) / 2;
if (isInMoon(mid01X01, mid01Y01)) {
goto lable910;
}
else//注意此时,mid01X01,Y01不在Moon内了,已经
{
X001 = mid01X01; Y01 = mid01Y01; //相当于退回中点(中值点
goto lable510;
}
}//if110elseif140
//
//while (true);
//
//
}//
- vs2017宇宙最伟大IDE用Console等调试汇总
- c++Win32起始鼠标作图181101
- 用迭代法找(两圆的)交点-精确计算迭代并改进-数值周期1810
- 精度-比例关系181110P2点
- 用迭代法求找两圆交点-精度计算181111A
- 月亮型-大小圆-上下圆算法181121
- 用c++的数学计算及图形绘制总结之1/共4-181101
- 用c++做数学计算及图形绘制总结之2/4-181102
- 用c++做数学计算及图形绘制总结之3/4-181103
- 用c++做数学计算及图形绘制总结4/4-181104
- 用c++的移位代替乘除运算181105
- 重构billiard2圆相交-非递归181101-非预料内图形-原因分析181201
- 重构月亮型billiard202圆相交-非递归181102-非预料内图形-原因分析181202
- 重构月亮型billiard202圆相交-非递归181102b-非预料内图形-原因分析181202b
- 单椭圆(非递归)18圣诞后-ok版181225