💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
先上图: 初始参数(设置): //输入初始参数: 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); // // }//