# FalconView

25 Jan 2022 11:06 #233050 by Grotius
Replied by Grotius on topic FalconView
Hi,

Hi for drawing 3d arc and circles. You could apply the ais_shape directly with the following functions:
line 139

This is a precious code for retrieving (verifying) points on a 3d arc or circle.
example line 575

For retrieving xyz data of a shape, this is quite compact code. I think can be modified to other variants.
line 500

Ahh nice you used the occ example.
I had a question over there how to display 1.2 miljion lines from a pruca slicer ngc code.
I hope to solve that later on this day.

25 Jan 2022 14:35 #233071 by Reinhard
Replied by Reinhard on topic FalconView
Hi Grotius,

> Hi for drawing 3d arc and circles. You could apply the ais_shape directly with the following functions

I know the functions for 3 points of a circle, but the point is, when you parse gcode, you don't have 3 points of a circle.
... and using interpreter of linuxcnc means, you have to work with what you get.

Usually you have a start- and an endpoint and most probably the center of the circle. But with that 3 points only, you don't know, whether its a helix or a true 3D-circle. So you need some axis additionally ...

I don't know enuf math to do that sort of calculations on my own. With my java app I used jmonkey for 3D plots and that lib had a different primitive interface, so it was easy for me to implement a real 3D-circle.
With the infos from linuxcnc I'm stuck.
Even with the interpreter you use for your hal core - I don't know, how to calculate a circle ...

> I had a question over there how to display 1.2 miljion lines from a pruca slicer ngc code.

You need to use some kind of paging algo. Either on your own, or from an existing library.
For java there exists a library called 'glazedllists' - that's a perfect list implementation, which can handle lists of multiple times the size of you memory.

25 Jan 2022 14:56 - 25 Jan 2022 15:06 #233076 by Grotius
Replied by Grotius on topic FalconView
Hi Reinhard,

Maybe i can help you a little bit more with a circle or arc function.
Give me some info about input values and what you expect ot get out of the function.
Then i create a function for you.

You need to use some kind of paging algo. Either on your own, or from an existing library.
The master kenobi of opencascade over there has give me some fresh meat to investegate.

P,s.
In hal-core for every gcode line we know the startpoint and  the endpoint.
If its a arc or circle we also are interested in the centerpoint.
These points can be retrieved by some math with the I,J,k gcode values.

I don't know if lcnc is giving info about above points, but i suspect it would.

Last edit: 25 Jan 2022 15:06 by Grotius.

26 Jan 2022 16:21 #233191 by Reinhard
Replied by Reinhard on topic FalconView
Hi Grotius,

I'm sorry, but I forgot where I stored the tests to 3D-arcs. Some time passed since then.
From what I remember: I was struggling with vector form of circle. I took center->start and center->end as vectors and calculated the angle in between (all formulas from internet). But calculated angles where between 0 and 180° and I found no way to determine, whether the angle is below or above 180°.
I would be very happy, if you could shine me a light on that issue.

While preparing the answer, another stumbling block occurred to me.
Suppose you have a lathe that support turning tools and you want to workout something like this:

The lathe tool can move in X and Z only, so to mill the circles you have to turn the main spindle into indexed C-Axis and the circle will be worked out between X- and C-axis. How would you like to render a path preview?
The straight parts of the outline should be milled too.
##### Attachments:

26 Jan 2022 17:43 #233200 by Grotius
Replied by Grotius on topic FalconView
Hi Reinhard,

If you are interested in mouse xyz positions, i am working on a widget.
It has also a gui designer setup for the widget overlays.

About the arc or circle segment:
The function has a arc_start, arc_center, arc_endpoint as input.
line 1059
It gives the total arc_angle at line 1081. It does not matter
- Arc angle output in radians.
- To convert :
#define toDegrees (180.0/M_PI)

Then if you don't know if its a g2 or g3, you need to calculate the determinant. Let me know if this is the case.

For the lathe question,
This is a difficult thing to imagine without full chuck, spindle preview.
My first thought was something like this.

If the lathe had one extra axis, it could perform like a xyz mill.
Doing the jog while rotating the main chuck forward and backward's is a difficult gcode path.
It can be calculated or be processed, but it's a hell of a job to code this.

28 Jan 2022 15:19 #233380 by Reinhard
Replied by Reinhard on topic FalconView
Hi,

> If you are interested in mouse xyz positions ...

Not really. I designed the application so that you can use it without a mouse (I had a control panel with hardware buttons in mind).

> About the arc or circle segment

Thank you for the pointer. I'll have to take a closer look at that in a quiet minute.

> If the lathe had one extra axis, it could perform like a xyz mill.

No! No extra axis.

> Doing the jog while rotating the main chuck forward and backward's is a difficult gcode path.
> It can be calculated or be processed, but it's a hell of a job to code this.

Hm, I guess, its similar to a 5axis-mill, where the table is fixed and the mill-head rotates (or a robot needs to perform similar moves).
Could that kind of movement be hidden in a tcp-kinematic?

31 Jan 2022 14:48 - 31 Jan 2022 14:51 #233636 by Grotius
Replied by Grotius on topic FalconView
Hi Reinhard,

There is a method  to avoid the start angle is bigger then the end angle value. When calculating angles in radians,
it adds 2 times 3.14 (pi) to the end angle value like :

If end_angle is smaller then start angle do:
end_angle += 2*M_PI
or
EA = EA + (2*3.14...)
Where M_PI is the same as PI (3.14...)

In the previous link there is a "atan2" function.
You have to normalize first. This is like bringing back one value to 0 ->
Xe = Endpoint_x - Centerpoint_x.
Ye = Endpoint_y - Centerpoint_y.
start_angle = atan2( Ye,  Xe );
Xs = Startpoint_x - Centerpoint_x.
Ys = Startpoint_y - Centerpoint_y.
start_angle = atan2( Ys,  Xs );

To use the atan2 in  Java:
```public static double atan2(double ye, double xe) {
return StrictMath.atan2(ye, xe); // default impl. delegates to StrictMath
}```
```public static double atan2(double ys, double xs) {
return StrictMath.atan2(ye, xe); // default impl. delegates to StrictMath
}```
Then for a circle circumfence lenght:
CL = diameter * M_PI.

Then for a arc lenght, a chunk of the circle cirumfence :
L = netto_arc_angle / ( 2 * 3.14..) * CL.
Last edit: 31 Jan 2022 14:51 by Grotius.

31 Jan 2022 15:03 #233637 by Grotius
Replied by Grotius on topic FalconView
Hm, I guess, its similar to a 5axis-mill,

So far as i can understand your implementation it looks like it are 2 kinematic chains.

The first chain is the lathe bed, for example x, y trans axis,  mounted a mill motor on the last axis.
The second chain is the lathe chuck, rotational axis.

Then when rotating the lathe chuck, the x,y trans axis cannot follow a fixed point at the chuck plane while rotating 360 degrees.

Or is it done another way?

31 Jan 2022 15:40 #233642 by Reinhard
Replied by Reinhard on topic FalconView
Hi Grotius,

Regarding toolpath - I accept, that it works with atan2, even if I don't understand it. So its ok.
Actually I'm trying to get into CavalierContour and polylines ...

I finally tried blender cam and it does not work at all. So current situation is: no hobby-cam provides workpath generation like I'm coding at work. Therefore I try to create a cam (well 2D only, as deskproto does a good job with 3D and 4-axis milling).

> The first chain is the lathe bed, for example x, y trans axis,  mounted a mill motor on the last axis.
> The second chain is the lathe chuck, rotational axis.

> Then when rotating the lathe chuck, the x,y trans axis cannot follow a fixed point at the chuck plane while rotating 360
degrees.

No, it does not work that way.
First lathe tool moves in X- and Z-direction. X is radial and Z is axial movement. Tooltip moves on a x-vector that crosses center of workpiece.

With turning tools, Spindle is switched from turning mode into indexed motion, which means, Spindle rotates (slowly?) between 0 and 360° (in both directions). So if you want to mill a cylinder pocket, tool moves ±X and Spindle moves between upper and lower angle of the circle. And for the straight lines you have both movements too.

02 Feb 2022 08:18 - 02 Feb 2022 08:19 #233778 by Grotius
Replied by Grotius on topic FalconView
Hi Reinhard,

I am a little confused. Maybe show a picture of the machine setup.

For the cavalier contours, i used a older release in my projects. Where the arc outputs are max 180 degrees.
Cavaliercontours works with bulges. In my code there are different algo's to read out the arc bulge's and convert them
back to a normal arc.

To get a succesfull output keep in mind:
1. Read the dxf, re-arrange the items into a group for every contour. Items must be arranged such that next xyz item is attached to a previous xyz item.
2. Perform a clockwise or ccw to get a inside or outside offset. Offcourse you can use pos or neg offset input values.

Different algo's are used, like
1. Swap or mirror.
2. Compare startpoints, endpoints within a margin.
3. Filter out points.
4. Array copy.
5. Notice a swap with a 4 (even) or 5 (uneven) number of items.

Last edit: 02 Feb 2022 08:19 by Grotius.