Android Question Arc Through 3 Points

Terradrones

Active Member
Hi All

I need help again please. I use a Canvas to plot all the Topo Points, which have been adjusted according to the Screen Scale. As the Surveyor picks up new Points, these also get plotted on the screen. The option also exists to plot the Elevation and Code of each Point as per the selected Font Size.

Then I have a small CAD option where the Surveyor can draw in Straight Lines and Texts, as per the selected color and Text size. The Survey and the CAD gets stored in 2 different SQLite Files.

Here is my problem: how can I draw in a Arc by selecting 3 different Topo Points. As an example, if I pick up 3 Points on a Bellmouth (Start, Center & End) , I can calculate the radius of the Bellmouth and draw in the Bellmouth.

I have the formulae to calculate all this. My problem is how to draw it on the same Canvas as where I plot my Topo Points, straight lines and Text.

I have had a look at ABExtDrawing, but don't have a clue what is going on there.
 

MicroDrie

Well-Known Member
Licensed User
Have you already taken a look at the many possibilities of Klaus's xChart Class and b4xlib? Because it is cross platform, you can easily develop and test your solution in B4J and then import it to B4A.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
I think that the answer is the same as the one to your recent post about canvases : use separate layers for different jobs. Imagine this -

1. You have several map layers, based on full screen panels. The bottom layer probably contains an imageView on which you have loaded your underlying map tile.
2. Above this you can have as many "layers" as you like. Each layer is a transparent panel with associated canvas. Each layer has a specific role - one might carry annotations, another might carry line drawings, and different layers could contain drawings for different feature types. We could call these "feature layers". Or you could just stuff everything on one panel/canvas.
3. The second-from-top layer is a final panel/canvas pair - this is your "working layer".
3. The top layer is simply a transparent panel. Its job is to pick up touch events.

Now, if the user want to draw a line he presses some button which is labelled "Draw arc". He makes three touch-downs on the top panel, but the arc is drawn on the canvas of the "working layer". If the user is happy then he presses another button that says "Done" and the line is copied to the appropriate feature layer, and the working layer is cleared. But the benefit of having the working layer is that, if the line is misdrawn then another "Erase" button can quickly clear that canvas ready for a second go.

Things get more complicated if you want to be able to pan the underlying map, but it is just a matter of doing the sums and redrawing the overlays with new coordinates. The maths in the main is only addition and subtraction. And there is nothing wrong with having a separate canvas for every drawn line - that would make it easy to delete or modify individual features, although there are probably better ways to manage that if you are writing a serious mapping application.
 
Upvote 0

Terradrones

Active Member
Hi Brain, I am doing all of that. I am using the same principal as a CAD program where different things get done on different Layers. The Panning is also sorted as you said by applying simple additions and subtractions to the limits of the coordinates.

Its a simple CAD routine that I have to let the Surveyor in the Field semi-complete his\she drawing.

I know how to calculate an Arc passing through 3 Points. My problem is how do I draw it on a Canvas using the 3 Points with the calculated Radius and Coordinates of the Center Point.

Code:
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
My problem is how do I draw it on a Canvas . . .
Okay - I understand. You want to know how to calculate the vertices for a canvas.DrawPath routine. I have done that in an old desktop application. It will take me a while to dig it up, unless @emexes gets there first.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
If I understand well, you want to click on three points on the screen and draw the arc between the two external points.
This means that you need to detect if a point is in the neighborhood of the current coordinates.
Here you need to convert the current 'mouse' coordinates to physical coordinates and check if a point is in the vicinity.
If yes, memorize the coordinates of the point
Do you have already this feature ?


I have the formulae to calculate all this. My problem is how to draw it on the same Canvas as where I plot my Topo Points, straight lines and Text.
This means that you have the coordinates of three points.
Then you can calculate the two angles between the two points and the center, and therefore draw the arc.
You must use the same scale as for the other points.
 
Last edited:
Upvote 0

Terradrones

Active Member
If I understand well, you want to click on three points on the screen and draw the arc between the two external points.
This means that you need to detect if a point is in the neighborhood of the current coordinates.
Here you need to convert the current 'mouse' coordinates to physical coordinates and check if a point is in the vicinity.
If yes, memorize the coordinates of the point
Do you have already this feature ?



This means that you have the coordinates of two points and the center.
Then you can calculate the the two angles between the two points and the center, and therefore draw the arc.
You must use the same scale as for the other points.
Hi Klaus, that is exactly what I want to do. When I lift my finger from the screen, I take the screen coordinates and convert them to world coordinates and I check to which Topo Point my finger was closest to and lock onto that Topo Point. The same I do for the other 2 Topo Points.

You showed me how I could draw a straight line and while moving my finger over the screen, it drew a line from the first Topo point to my finger, but deleting the previously drawn line. It only drew a line as part of the Survey when I lifted my finger. Again the line locked onto the closest Topo Point.

I would like to do the same with a 3 Point Arc.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Here you are.

Attached you find a B4XPages project doing it.
Not tested with B4i.

The project works with three Panels and three B4XCanvases.
One for the graph, one temporary for the green intermediate lines and one for the cursor.

Click on Add Arc, then you can select the three points with the cursor,
When the cursor is on a point, this one is highlighted.
After having selected the three points, the circle is calculated.
Press on OK, the arc is drawn onto the Graphic.
The routine to draw the arc is a specific one.
The cursor has a vertical offset to show it above the finger.
1690294986955.png
1690295098080.png
1690295198472.png
1690295466139.png
 

Attachments

  • 1690294874538.png
    1690294874538.png
    19.7 KB · Views: 39
  • 1690295179784.png
    1690295179784.png
    34.2 KB · Views: 35
  • 1690295421725.png
    1690295421725.png
    29.9 KB · Views: 39
  • ArcThrrePoints.zip
    20.2 KB · Views: 51
Upvote 0
Top