QT C++ code samples
02 Aug 2019 14:38 #141188
by Grotius
Replied by Grotius on topic QT C++ code samples
Attachments:
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
02 Aug 2019 17:15 - 02 Aug 2019 18:26 #141207
by Grotius
Replied by Grotius on topic QT C++ code samples
Thank you Phill and Tommy,
I hope soon we make progress. It's a long way to the top for sure...
We have a closed contour, and i was curious about other cam program's so i tested this example in sheetcam.
Sheetcam output :
Dxfdecoder output :
Why has sheetcam no full output for this example?
Another example of a more complex shape :
Sheetcam output :
DxfDecoder output :
Okey a while ago i learned from Rodw how to use Switch state's in C, used for custom linux plasma component's that time.
I integrated the switch statement as C code into the C++ dxfdecoder project to startup a structure that deals with multiple contour offset's and mutiple intersection types, like line-line, line-arc, arc-arc and visa versa.
The finishing touch of a nice program that can do contour offset's needs this structure now...
WIth the knowlegde we now have, we could make a open source autocad program, with more function's for sure !!
We only have to add some student's for help coding the program.
Or a program like facebook or watsapp. Or a improvement of youtube called mytube...
Or something else. Can be almost everything.. A global window's 7 update destroyer looks funny to make, but it's not legal to write program's with this purpose this day's. It's only legal if you carry the name America and write some Stuxnet code that involves innocent pc's worldwide. Then it's legal...
In the store i can only buy a new pc with a American Window's Licence. It's to crazy to be true.
This must change soon. It's not a fair trade...
The last time we did a software stress test. Now this one. What is left?
I hope soon we make progress. It's a long way to the top for sure...
We have a closed contour, and i was curious about other cam program's so i tested this example in sheetcam.
Sheetcam output :
Dxfdecoder output :
Why has sheetcam no full output for this example?
Another example of a more complex shape :
Sheetcam output :
DxfDecoder output :
Okey a while ago i learned from Rodw how to use Switch state's in C, used for custom linux plasma component's that time.
I integrated the switch statement as C code into the C++ dxfdecoder project to startup a structure that deals with multiple contour offset's and mutiple intersection types, like line-line, line-arc, arc-arc and visa versa.
The finishing touch of a nice program that can do contour offset's needs this structure now...
WIth the knowlegde we now have, we could make a open source autocad program, with more function's for sure !!
We only have to add some student's for help coding the program.
Or a program like facebook or watsapp. Or a improvement of youtube called mytube...
Or something else. Can be almost everything.. A global window's 7 update destroyer looks funny to make, but it's not legal to write program's with this purpose this day's. It's only legal if you carry the name America and write some Stuxnet code that involves innocent pc's worldwide. Then it's legal...
In the store i can only buy a new pc with a American Window's Licence. It's to crazy to be true.
This must change soon. It's not a fair trade...
The last time we did a software stress test. Now this one. What is left?
Attachments:
Last edit: 02 Aug 2019 18:26 by Grotius.
Please Log in or Create an account to join the conversation.
03 Aug 2019 18:30 - 03 Aug 2019 19:34 #141282
by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,
We got the contour offset algoritme working now for multiple product's at the moment. Still only line-line intersection.
We got a inside and a outside offset. The logic about this i have to integrate coming time. The only logic about this at the moment is that it depends on the contour direction.
The next step is to add a line-arc intersection offset to the closed contour.
Today was quite a difficult piece of code to understand. Next time i will make a code template with only a debug output first.
This will display's the correct output first in text form.
After the correct text output flow is approved, we can implement the function's to it. This will make the coding much easyer.
Sometimes you get blind with so many trees in the forest.
DxfDecoder output :
Most of the code that i did today is attached as a picture. In Qt it looks nicer !
Mention that display a text output or a value to a terminal (console) in C++ is much easyer then in C.
This saves you so much time.. C++ is much more automated then C.
We got the contour offset algoritme working now for multiple product's at the moment. Still only line-line intersection.
We got a inside and a outside offset. The logic about this i have to integrate coming time. The only logic about this at the moment is that it depends on the contour direction.
The next step is to add a line-arc intersection offset to the closed contour.
Today was quite a difficult piece of code to understand. Next time i will make a code template with only a debug output first.
This will display's the correct output first in text form.
After the correct text output flow is approved, we can implement the function's to it. This will make the coding much easyer.
Sometimes you get blind with so many trees in the forest.
DxfDecoder output :
Most of the code that i did today is attached as a picture. In Qt it looks nicer !
Mention that display a text output or a value to a terminal (console) in C++ is much easyer then in C.
This saves you so much time.. C++ is much more automated then C.
Attachments:
Last edit: 03 Aug 2019 19:34 by Grotius.
Please Log in or Create an account to join the conversation.
05 Aug 2019 15:13 #141427
by Grotius
Replied by Grotius on topic QT C++ code samples
Attachments:
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
06 Aug 2019 22:56 - 07 Aug 2019 00:46 #141550
by Grotius
Replied by Grotius on topic QT C++ code samples
Hi,
We have a little update.
The idea is to adapt standard cad function's, like drawing a line, circle, etc to the program.
So we added the draw line function today.
- It has an F8 keyboard button for "ortho on" and "ortho off" toggle, to draw a vertical or horizontal line without gambling.
- The line follow's you mouse while drawing the second point.... Wow...
- At the mouse pointer you see how long the line is. In the below screen you see the global mouse position, this is nice !!
- We did not a draftsight decompile... Haha... We did not steal the source code... Haha. It was much easyer. We write the source code our own. We write code with much more power. Linux Power !!
Added a terminal command window below to enter your line lenght or wathever the message box is asking you...
We must get rid of empty window space, just like draftsight. The command line in draftsight fill's the entire screen from left to right.
Hopefully we will make a difference in all kind of detail's and add magic function's.
Why do i do this?
Drafsight has another update to migrate from 2018 to 2019. For window's the program is not free anymore.
How about next year, will draftsight be free for linux? We will not wait untill it's unplugged by Autodesk.
Just provide a open source cad program. It's not so hard to write some text in C++.
See the list of cad program's
partsolutions.com/60-years-of-cad-infogr...y-of-cad-since-1957/
My goal is : the next one on the list will last for 1000 years and is free for everyone. Okey we have freecad etc. Maybe that software will be on the list..
Let's compile for linux, window's, mac and for everyone that want a free cad program without staying with a update licence
a 200 dollars a year.
The name PRONTO CAD 2019 is a good name.... Or maybe OGCC, "Open Grotius Cad Cam" ....
Drafsight is written in QT C++. .. Haha we write with the same development package, we as inventor's, professor's, linux guru's
we have much more practical experience in writing function's up to complex algoritme's.
The idea of CAD has grown from simple 2D designs into complex, multi-layered 3D structures with kinematic-movement and detailed meta-data
Ai ai... Kinematic movement's, we can try to add tomorrow... Meta data is crap.
We have a little update.
The idea is to adapt standard cad function's, like drawing a line, circle, etc to the program.
So we added the draw line function today.
- It has an F8 keyboard button for "ortho on" and "ortho off" toggle, to draw a vertical or horizontal line without gambling.
- The line follow's you mouse while drawing the second point.... Wow...
- At the mouse pointer you see how long the line is. In the below screen you see the global mouse position, this is nice !!
- We did not a draftsight decompile... Haha... We did not steal the source code... Haha. It was much easyer. We write the source code our own. We write code with much more power. Linux Power !!
Added a terminal command window below to enter your line lenght or wathever the message box is asking you...
We must get rid of empty window space, just like draftsight. The command line in draftsight fill's the entire screen from left to right.
Hopefully we will make a difference in all kind of detail's and add magic function's.
Why do i do this?
Drafsight has another update to migrate from 2018 to 2019. For window's the program is not free anymore.
How about next year, will draftsight be free for linux? We will not wait untill it's unplugged by Autodesk.
Just provide a open source cad program. It's not so hard to write some text in C++.
See the list of cad program's
partsolutions.com/60-years-of-cad-infogr...y-of-cad-since-1957/
My goal is : the next one on the list will last for 1000 years and is free for everyone. Okey we have freecad etc. Maybe that software will be on the list..
Let's compile for linux, window's, mac and for everyone that want a free cad program without staying with a update licence
a 200 dollars a year.
The name PRONTO CAD 2019 is a good name.... Or maybe OGCC, "Open Grotius Cad Cam" ....
Drafsight is written in QT C++. .. Haha we write with the same development package, we as inventor's, professor's, linux guru's
we have much more practical experience in writing function's up to complex algoritme's.
The idea of CAD has grown from simple 2D designs into complex, multi-layered 3D structures with kinematic-movement and detailed meta-data
Ai ai... Kinematic movement's, we can try to add tomorrow... Meta data is crap.
Attachments:
Last edit: 07 Aug 2019 00:46 by Grotius.
Please Log in or Create an account to join the conversation.
07 Aug 2019 20:23 #141631
by Grotius
Replied by Grotius on topic QT C++ code samples
Thank you phillc54, tommylight, Clive s,
Today we added the function draw a 2 point and a 3 point circle. While drawing, update the circle off course.
I mentioned freecad has no 3p circle. In draftsight you have to enter it in the command line wile drawing a 2p circle.
The C++ code for calculating a 3p circle is attached. Maybe freecad can use this code also.
Okey this works nice. Next item to draw is a 3 point arc... This is in fact a 3p circle, but with start_angle and end_angle, combined
with xy_start and xy_end coordinates to make it a succesful story. Keep up the good work !
Today we added the function draw a 2 point and a 3 point circle. While drawing, update the circle off course.
I mentioned freecad has no 3p circle. In draftsight you have to enter it in the command line wile drawing a 2p circle.
The C++ code for calculating a 3p circle is attached. Maybe freecad can use this code also.
Warning: Spoiler!
if(draw3pcircle_mode == 1){
if(click == 2){ // after second click, show the thirth circle point as the actual mouse position
X3 = gl_mousepos_x;
Y3 = gl_mousepos_y;
//calculate 3 point circle... calculate xy center and radius..
// Get the perpendicular bisector of (x1, y1) and (x2, y2).
double x1 = (X2 + X1) / 2;
double y1 = (Y2 + Y1) / 2;
double dy1 = X2 - X1;
double dx1 = -(Y2 - Y1);
// Get the perpendicular bisector of (x2, y2) and (x3, y3).
double x2 = (X3 + X2) / 2;
double y2 = (Y3 + Y2) / 2;
double dy2 = X3 - X2;
double dx2 = -(Y3 - Y2);
double endpoint_x0 = x1 + dx1;
double endpoint_y0 = y1 + dy1;
double endpoint_x1 = x2 + dx2;
double endpoint_y1 = y2 + dy2;
//line 1
double delta_y0 = endpoint_y0 - y1;
double delta_x0 = x1 - endpoint_x0;
double c0 = delta_y0 * x1 + delta_x0 * y1;
//line 2
double delta_y1 = endpoint_y1 - y2;
double delta_x1 = x2 - endpoint_x1;
double c1 = delta_y1 * x2 + delta_x1 * y2;
double determinant = delta_y0*delta_x1 - delta_y1*delta_x0;
//qDebug() << "determinant is : " << determinant;
if (determinant == 0) // The lines are parallel.
{
//qDebug() << "the lines are parallel";
}
else {
double x_center = (delta_x1*c0 - delta_x0*c1)/determinant;
double y_center = (delta_y0*c1 - delta_y1*c0)/determinant;
double dx = x_center - X1;
double dy = y_center - Y1;
double radius = sqrt(dx * dx + dy * dy);
qDebug() << " intersection point is x : " << x_center << " y : " << y_center << " radius : " << radius;
double_cad_array[cad_counter][0][6] = x_center;
double_cad_array[cad_counter][0][7] = y_center;
double_cad_array[cad_counter][0][9] = radius;
}
}
}
if(click == 2){ // after second click, show the thirth circle point as the actual mouse position
X3 = gl_mousepos_x;
Y3 = gl_mousepos_y;
//calculate 3 point circle... calculate xy center and radius..
// Get the perpendicular bisector of (x1, y1) and (x2, y2).
double x1 = (X2 + X1) / 2;
double y1 = (Y2 + Y1) / 2;
double dy1 = X2 - X1;
double dx1 = -(Y2 - Y1);
// Get the perpendicular bisector of (x2, y2) and (x3, y3).
double x2 = (X3 + X2) / 2;
double y2 = (Y3 + Y2) / 2;
double dy2 = X3 - X2;
double dx2 = -(Y3 - Y2);
double endpoint_x0 = x1 + dx1;
double endpoint_y0 = y1 + dy1;
double endpoint_x1 = x2 + dx2;
double endpoint_y1 = y2 + dy2;
//line 1
double delta_y0 = endpoint_y0 - y1;
double delta_x0 = x1 - endpoint_x0;
double c0 = delta_y0 * x1 + delta_x0 * y1;
//line 2
double delta_y1 = endpoint_y1 - y2;
double delta_x1 = x2 - endpoint_x1;
double c1 = delta_y1 * x2 + delta_x1 * y2;
double determinant = delta_y0*delta_x1 - delta_y1*delta_x0;
//qDebug() << "determinant is : " << determinant;
if (determinant == 0) // The lines are parallel.
{
//qDebug() << "the lines are parallel";
}
else {
double x_center = (delta_x1*c0 - delta_x0*c1)/determinant;
double y_center = (delta_y0*c1 - delta_y1*c0)/determinant;
double dx = x_center - X1;
double dy = y_center - Y1;
double radius = sqrt(dx * dx + dy * dy);
qDebug() << " intersection point is x : " << x_center << " y : " << y_center << " radius : " << radius;
double_cad_array[cad_counter][0][6] = x_center;
double_cad_array[cad_counter][0][7] = y_center;
double_cad_array[cad_counter][0][9] = radius;
}
}
}
Okey this works nice. Next item to draw is a 3 point arc... This is in fact a 3p circle, but with start_angle and end_angle, combined
with xy_start and xy_end coordinates to make it a succesful story. Keep up the good work !
Attachments:
The following user(s) said Thank You: tommylight
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 15512
- Thank you received: 5150
07 Aug 2019 20:57 #141633
by tommylight
Replied by tommylight on topic QT C++ code samples
You have become a "one man software development team " !
Respect, you have earned it.
Respect, you have earned it.
The following user(s) said Thank You: Grotius
Please Log in or Create an account to join the conversation.
07 Aug 2019 22:12 #141636
by Clive S
Replied by Clive S on topic QT C++ code samples
Yes Grotius. I don't understand that much are what you are doing but I do understand the amount of work that is going into this project and the effort you have put in. I follow along the best I can.
The following user(s) said Thank You: Grotius
Please Log in or Create an account to join the conversation.
07 Aug 2019 23:16 #141637
by Grotius
Replied by Grotius on topic QT C++ code samples
Hi Clive and Tommy,
Thank you for your kind words!!
It's nice to hear some feedback!! It give's power...
For cad there are so much new function's to integrate, like a button for drawing a inline circle inside a 3 point triangle.
Wich is difficult to draw your own, unless you make some help lines first. Or draw a inline circle inside a contour automaticly.
The more we get involved into this project, the more new solution's we see.
We don't have a time limit.
Some of the code templates are worth more then real diamonts.
Thank you for your kind words!!
It's nice to hear some feedback!! It give's power...
For cad there are so much new function's to integrate, like a button for drawing a inline circle inside a 3 point triangle.
Wich is difficult to draw your own, unless you make some help lines first. Or draw a inline circle inside a contour automaticly.
The more we get involved into this project, the more new solution's we see.
We don't have a time limit.
Some of the code templates are worth more then real diamonts.
Attachments:
Please Log in or Create an account to join the conversation.
09 Aug 2019 23:12 - 10 Aug 2019 01:10 #141820
by Grotius
Replied by Grotius on topic QT C++ code samples
Hi phillc54, tommylight & Clive s,
You are perfect !! Wow. The idea we have a strong community with soul member's.. The open source facility... The interest... The time we invest to make thing better for next generation's.. Wow. We can write history if we go on this way for sure !!
Elon Musk is clear about open source. Everything will be open source within a certain time. Think about where to buy a linux pc or laptop. The trade is not fair at this moment. Every laptop has windows 10 for 150 euro's. I don't need window's ......
Maybe with the next auto window's update, we let the customer choose the system.. let the customer choose : free or non free.
So maybe i tell some authority about trade mistake's that are going on. Customer can deside what he want's on the pc, that is fare trade. Let window's go a few step's down's please...
Today we added the polygon function to the cad interface. Yesterday the arc function was ready. The arc source code has exact the same features as autodesk and some improvements related to drawing arc's.. perfect done !!
A screenshot of several cad functions :
- lines ( ortho on or off (F8 toggle) )
- linestrip ( ortho on or off (F8 toggle) )
- arc's ( very clever function for cw and ccw arc's )
- rectangular
- polygon ( give up the sides in terminal, it's react's on even and odd polygon's, output is very good !! )
It looks like a Egyptian hyroglypics text, isn't it...
Now we started coding the ellipse function. This is a nice exotic function to integrate, it's a little special in this case.
We don't want a conventional ellipse (one liner). We can use a ellipse on a cnc when it's build up from multiple arc's. So in that case we must make a ellipse C++ template algortime. Nice !!
The cad template to draw the ellipse is in fact the source code for the C++ template algoritme.
If we follow the steps of drawing the ellipse in cad, we can write the C++ code the same way, so in fact drawing something has the same logic as coding something...
The most difficult part is debugging the step's. ( debugging is in fact : every step you make, check this step in output if it's correct. )
Okey how to define a ellipse in Cad :
So there was a youtube video about this how to draw (define) a ellipse yourself.
I started coding the ellipse. Within 2 day's it's ready.
Did you realise a kwart 1/4 ellipse can be a perfect chamfer option for 2 lines instead of a segment of a circle or a arc....
An ellipse with the same base and height is a full circle. But it has some improvement's that i did not realise until i start working
with this exotic piece of mathematical workspace.
The ellipse chamfer function, wich does not extist chamfers with material reduction in a natural perfect way. Given a perfect
end shape output. We will show and start that option soon. The ellipse chamfer solution is a nice one for the pocket !!!
Autodesk can not do this, because they use ellipse one liner's...
40 years of autodesk coding, where is the logic? Maybe they can dot it. but have no good coders....
Polygon C++ source code :
Mention... The open gl is no display management sytem...
Everything you have to code yourself... Make your coding stratagy.. That's what top coder's have to say about opengl.
For fun i think about integrating :
In Math's i suspect there is a gab in the Pi value... Can a Pi value be updated? In Radian's it has no unexpected values... but it also in radians we have PI.. or M_PI for C++.. Fuck !! How to get rid of PI and solve the problem...
For example,
if you calculate 4 arc's as ellipse that imagine a full circle in double. (defined as about 16 digit's... (2x accuray of float))
What is the difference when calculating the same as one liner circle with given : M_PI...
Never seen any comparishment's about this....
We will calculate the difference of PI some how in combination of a 4-arc's circle to a one liner circle.
And i think the 4 -arc's are more clever in output before i start the calculation. Why??
It can be a output of ^4 more PI accuracy for example.
You are perfect !! Wow. The idea we have a strong community with soul member's.. The open source facility... The interest... The time we invest to make thing better for next generation's.. Wow. We can write history if we go on this way for sure !!
Elon Musk is clear about open source. Everything will be open source within a certain time. Think about where to buy a linux pc or laptop. The trade is not fair at this moment. Every laptop has windows 10 for 150 euro's. I don't need window's ......
Maybe with the next auto window's update, we let the customer choose the system.. let the customer choose : free or non free.
So maybe i tell some authority about trade mistake's that are going on. Customer can deside what he want's on the pc, that is fare trade. Let window's go a few step's down's please...
Today we added the polygon function to the cad interface. Yesterday the arc function was ready. The arc source code has exact the same features as autodesk and some improvements related to drawing arc's.. perfect done !!
A screenshot of several cad functions :
- lines ( ortho on or off (F8 toggle) )
- linestrip ( ortho on or off (F8 toggle) )
- arc's ( very clever function for cw and ccw arc's )
- rectangular
- polygon ( give up the sides in terminal, it's react's on even and odd polygon's, output is very good !! )
It looks like a Egyptian hyroglypics text, isn't it...
Now we started coding the ellipse function. This is a nice exotic function to integrate, it's a little special in this case.
We don't want a conventional ellipse (one liner). We can use a ellipse on a cnc when it's build up from multiple arc's. So in that case we must make a ellipse C++ template algortime. Nice !!
The cad template to draw the ellipse is in fact the source code for the C++ template algoritme.
If we follow the steps of drawing the ellipse in cad, we can write the C++ code the same way, so in fact drawing something has the same logic as coding something...
The most difficult part is debugging the step's. ( debugging is in fact : every step you make, check this step in output if it's correct. )
Okey how to define a ellipse in Cad :
So there was a youtube video about this how to draw (define) a ellipse yourself.
I started coding the ellipse. Within 2 day's it's ready.
Did you realise a kwart 1/4 ellipse can be a perfect chamfer option for 2 lines instead of a segment of a circle or a arc....
An ellipse with the same base and height is a full circle. But it has some improvement's that i did not realise until i start working
with this exotic piece of mathematical workspace.
The ellipse chamfer function, wich does not extist chamfers with material reduction in a natural perfect way. Given a perfect
end shape output. We will show and start that option soon. The ellipse chamfer solution is a nice one for the pocket !!!
Autodesk can not do this, because they use ellipse one liner's...
40 years of autodesk coding, where is the logic? Maybe they can dot it. but have no good coders....
Polygon C++ source code :
Mention... The open gl is no display management sytem...
Everything you have to code yourself... Make your coding stratagy.. That's what top coder's have to say about opengl.
Warning: Spoiler!
if(drawpolygon_mode == 1){
//result = asin (param) * 180.0 / PI;
//X = Cx + (r * cosine(angle))
//Y = Cy + (r * sine(angle))
//float angle between 2 points = atan2(p1.y - p2.y, p1.x - p2.x)* 180.0 / PI;
double x3;
double y3;
double x4;
double y4;
bool even;
click++;
if(click == 1){
qDebug() << "click = 1";
//mouse clicked center xy of polygon
x_center = gl_mousepos_x; //center x
y_center = gl_mousepos_y; //center y
}
if(click == 2){
qDebug() << "click = 2";
//mouse clicked radius of polygon
x_start = gl_mousepos_x; //radius x
y_start = gl_mousepos_y; //radius y
dist_x = x_start - x_center;
dist_y = y_start - y_center;
radius = sqrt(pow(dist_x,2) + pow(dist_y,2)); //radius
qDebug() << "radius is : " << radius;
cake_angle = 360 / polygon_sides;
qDebug() << "cake angle is : " << cake_angle;
if (terminal_text_int % 2 == 0){
even = 1;
qDebug() << "value is even";
} else {
even = 0;
qDebug() << "value is odd";
}
if(F8 == 0){ //ortho off
if(even == 1){
//next polygon lines....
start_angle = atan2(y_center - y_start, x_center - x_start)* 180.0 / M_PI;
qDebug() << "start_angle = " << start_angle;
for(int i=0; i<polygon_sides; i++){
x3 = x_center + (radius * cos ( start_angle * M_PI / 180.0 ));
y3 = y_center + (radius * sin ( start_angle * M_PI / 180.0 ));
x4 = x_center + (radius * cos ( (start_angle + cake_angle) * M_PI / 180.0 ));
y4 = y_center + (radius * sin ( (start_angle + cake_angle) * M_PI / 180.0 ));
int_cad_array[cad_counter][0][0] = 1; //id is line
double_cad_array[cad_counter][0][0] = x3;
double_cad_array[cad_counter][0][1] = y3;
double_cad_array[cad_counter][0][3] = x4;
double_cad_array[cad_counter][0][4] = y4;
cad_counter++;
start_angle += cake_angle;
//qDebug() << "start_angle = " << start_angle;
}
cad_counter++;;
}
if(even == 0){
//next polygon lines....
start_angle = atan2(y_center - y_start, x_center - x_start)* 180.0 / M_PI;
qDebug() << "start_angle = " << start_angle;
for(int i=0; i<polygon_sides; i++){
x3 = x_center + (radius * cos ( (start_angle + (0.5*cake_angle)) * M_PI / 180.0 ));
y3 = y_center + (radius * sin ( (start_angle + (0.5*cake_angle)) * M_PI / 180.0 ));
x4 = x_center + (radius * cos ( ((start_angle + cake_angle) + (0.5*cake_angle)) * M_PI / 180.0 ));
y4 = y_center + (radius * sin ( ((start_angle + cake_angle) + (0.5*cake_angle)) * M_PI / 180.0 ));
int_cad_array[cad_counter][0][0] = 1; //id is line
double_cad_array[cad_counter][0][0] = x3;
double_cad_array[cad_counter][0][1] = y3;
double_cad_array[cad_counter][0][3] = x4;
double_cad_array[cad_counter][0][4] = y4;
cad_counter++;
start_angle += cake_angle;
//qDebug() << "start_angle = " << start_angle;
}
cad_counter++;
}
}
if(F8 == 1){ //ortho on
//next polygon lines....
start_angle = cake_angle;
for(int i=0; i<polygon_sides; i++){
x3 = x_center + (radius * cos ( start_angle * M_PI / 180.0 ));
y3 = y_center + (radius * sin ( start_angle * M_PI / 180.0 ));
x4 = x_center + (radius * cos ( (start_angle + cake_angle) * M_PI / 180.0 ));
y4 = y_center + (radius * sin ( (start_angle + cake_angle) * M_PI / 180.0 ));
int_cad_array[cad_counter][0][0] = 1; //id is line
double_cad_array[cad_counter][0][0] = x3;
double_cad_array[cad_counter][0][1] = y3;
double_cad_array[cad_counter][0][3] = x4;
double_cad_array[cad_counter][0][4] = y4;
cad_counter++;
start_angle += cake_angle;
//qDebug() << "start_angle = " << start_angle;
}
}
click = 0;
}
}
//result = asin (param) * 180.0 / PI;
//X = Cx + (r * cosine(angle))
//Y = Cy + (r * sine(angle))
//float angle between 2 points = atan2(p1.y - p2.y, p1.x - p2.x)* 180.0 / PI;
double x3;
double y3;
double x4;
double y4;
bool even;
click++;
if(click == 1){
qDebug() << "click = 1";
//mouse clicked center xy of polygon
x_center = gl_mousepos_x; //center x
y_center = gl_mousepos_y; //center y
}
if(click == 2){
qDebug() << "click = 2";
//mouse clicked radius of polygon
x_start = gl_mousepos_x; //radius x
y_start = gl_mousepos_y; //radius y
dist_x = x_start - x_center;
dist_y = y_start - y_center;
radius = sqrt(pow(dist_x,2) + pow(dist_y,2)); //radius
qDebug() << "radius is : " << radius;
cake_angle = 360 / polygon_sides;
qDebug() << "cake angle is : " << cake_angle;
if (terminal_text_int % 2 == 0){
even = 1;
qDebug() << "value is even";
} else {
even = 0;
qDebug() << "value is odd";
}
if(F8 == 0){ //ortho off
if(even == 1){
//next polygon lines....
start_angle = atan2(y_center - y_start, x_center - x_start)* 180.0 / M_PI;
qDebug() << "start_angle = " << start_angle;
for(int i=0; i<polygon_sides; i++){
x3 = x_center + (radius * cos ( start_angle * M_PI / 180.0 ));
y3 = y_center + (radius * sin ( start_angle * M_PI / 180.0 ));
x4 = x_center + (radius * cos ( (start_angle + cake_angle) * M_PI / 180.0 ));
y4 = y_center + (radius * sin ( (start_angle + cake_angle) * M_PI / 180.0 ));
int_cad_array[cad_counter][0][0] = 1; //id is line
double_cad_array[cad_counter][0][0] = x3;
double_cad_array[cad_counter][0][1] = y3;
double_cad_array[cad_counter][0][3] = x4;
double_cad_array[cad_counter][0][4] = y4;
cad_counter++;
start_angle += cake_angle;
//qDebug() << "start_angle = " << start_angle;
}
cad_counter++;;
}
if(even == 0){
//next polygon lines....
start_angle = atan2(y_center - y_start, x_center - x_start)* 180.0 / M_PI;
qDebug() << "start_angle = " << start_angle;
for(int i=0; i<polygon_sides; i++){
x3 = x_center + (radius * cos ( (start_angle + (0.5*cake_angle)) * M_PI / 180.0 ));
y3 = y_center + (radius * sin ( (start_angle + (0.5*cake_angle)) * M_PI / 180.0 ));
x4 = x_center + (radius * cos ( ((start_angle + cake_angle) + (0.5*cake_angle)) * M_PI / 180.0 ));
y4 = y_center + (radius * sin ( ((start_angle + cake_angle) + (0.5*cake_angle)) * M_PI / 180.0 ));
int_cad_array[cad_counter][0][0] = 1; //id is line
double_cad_array[cad_counter][0][0] = x3;
double_cad_array[cad_counter][0][1] = y3;
double_cad_array[cad_counter][0][3] = x4;
double_cad_array[cad_counter][0][4] = y4;
cad_counter++;
start_angle += cake_angle;
//qDebug() << "start_angle = " << start_angle;
}
cad_counter++;
}
}
if(F8 == 1){ //ortho on
//next polygon lines....
start_angle = cake_angle;
for(int i=0; i<polygon_sides; i++){
x3 = x_center + (radius * cos ( start_angle * M_PI / 180.0 ));
y3 = y_center + (radius * sin ( start_angle * M_PI / 180.0 ));
x4 = x_center + (radius * cos ( (start_angle + cake_angle) * M_PI / 180.0 ));
y4 = y_center + (radius * sin ( (start_angle + cake_angle) * M_PI / 180.0 ));
int_cad_array[cad_counter][0][0] = 1; //id is line
double_cad_array[cad_counter][0][0] = x3;
double_cad_array[cad_counter][0][1] = y3;
double_cad_array[cad_counter][0][3] = x4;
double_cad_array[cad_counter][0][4] = y4;
cad_counter++;
start_angle += cake_angle;
//qDebug() << "start_angle = " << start_angle;
}
}
click = 0;
}
}
For fun i think about integrating :
In Math's i suspect there is a gab in the Pi value... Can a Pi value be updated? In Radian's it has no unexpected values... but it also in radians we have PI.. or M_PI for C++.. Fuck !! How to get rid of PI and solve the problem...
For example,
if you calculate 4 arc's as ellipse that imagine a full circle in double. (defined as about 16 digit's... (2x accuray of float))
What is the difference when calculating the same as one liner circle with given : M_PI...
Never seen any comparishment's about this....
We will calculate the difference of PI some how in combination of a 4-arc's circle to a one liner circle.
And i think the 4 -arc's are more clever in output before i start the calculation. Why??
It can be a output of ^4 more PI accuracy for example.
Attachments:
Last edit: 10 Aug 2019 01:10 by Grotius.
Please Log in or Create an account to join the conversation.
Time to create page: 0.841 seconds