[SOLVED] Application capable of measuring angles and distances.

Mark Read

Well-Known Member
Licensed User
Longtime User
I have not tested the form resizing.

Changing the Draw function in B4XMainPage shows everything after resize. I am not familiar with the ClipPath function so I do not know what you wanted to do here.
However there are still a few minor problems: In full scrren mode, I cannot move the top of the crane further than the building. Aha, correction, you have limited the crane boom length amongst other things in the CraneObject Initialize class. Probably better to have inputs for these defaults, to make them easier to find. But still great work Klaus.

B4X:
Public Sub Draw
    If Mode = "Measure" Then Return

    pthScene.Initialize(SceneOriginX, 0)
    pthScene.LineTo(cvsGrid.TargetRect.Width, 0)
    pthScene.LineTo(cvsGrid.TargetRect.Width, SceneOriginY)
    pthScene.LineTo(SceneOriginX, SceneOriginY)
    'cvsScene.ClipPath(pthScene)                        <= Commented out
  
    cvsCursor.ClearRect(cvsScene.TargetRect)
    cvsScene.ClearRect(cvsScene.TargetRect)
    For o = 0 To ListObjects.Size - 1
        Private Obj As ObjectData
        Obj = ListObjects.Get(o)
        If Obj.ObjectType = "Building" Then
            Obj.Item.As(BuildingObject).Draw
        End If
    Next
    For o = 0 To ListObjects.Size - 1
        Private Obj As ObjectData
        Obj = ListObjects.Get(o)
        If Obj.ObjectType = "Load" Then
            Obj.Item.As(LoadObject).Draw
        End If
    Next
    For o = 0 To ListObjects.Size - 1
        Private Obj As ObjectData
        Obj = ListObjects.Get(o)
        If Obj.ObjectType = "Crane" Then
            Obj.Item.As(CraneObject).Draw
        End If
    Next
    cvsScene.Invalidate
End Sub
 
Last edited:

klaus

Expert
Licensed User
Longtime User
I have already changed the Draw method in my current version and the resizing works now.
The clipping path is used to limit the drawing on the diagram.
Otherwise, when you zoom, parts would be drawn on the left and the bottom of the scale.
The latest version has not yet been published.
I am going to remove the Scale mode and move the graphic with the right mouse button for B4J and with gestures on B4A.
 

amorosik

Expert
Licensed User
And how to proceed if we wanted to modify the program that you generously shared, to represent entities hinged to each other?
In essence, how to make the various components drawn move in order to obtain the L7 value?


 
Last edited:

klaus

Expert
Licensed User
Longtime User
You need to create a new class similar to the Crane class.
In the new class you need to declare the different parts, set their dimensions and define their degrees of liberty, define characteristic points, treat and calculate their movements in a Touch event or with sliders to modify their degrees of liberty.
The Touch event must be transmitted from the B4XMainPage module in the mouse and Gesture routines.
Then you need to choose what the user can do.
- Methods to set the angles of the four rotation points.
- Possible movements of the four points with the mouse, stylus or finger.
As an example: In the crane you can move the top of boom with the mouse, this implies a change of its length and rotation angle.
And with the sliders you can change the length and rotation angle independently like the real crane.
And of course this implies all the geometric calculations.
You know the different lengths and angles and you can calculate the different positions.
Or do you want to get all the equations for the calculation ?
 

amorosik

Expert
Licensed User

Yes, all dimensions and angles (L1, L2, L3, L6, DEG1, DEG10, DEG20, DEG30) are known (they are measured)
The value we want to calculate is L7
Value from which, by subtracting L8, you can understand how far the closed bucket is from the water surface, or from the bottom (L9)
 
Last edited:

William Lancee

Well-Known Member
Licensed User
Longtime User
I tried it out with: https://www.b4x.com/android/forum/t...-intersection-angles-draggable-points.163499/

Example:
Seabed y = 0
Water Surface y = 15
Bucket depth = 2

Reference = 20
Deg10 = 51.6 + 90 = 141.6
L1 = 30.1
Deg20 = 101.2
L2 = 18.1
Deg30 = 117.2
L3 = 24.2
L9 = top of bucket from seabed - bucket depth = 11.2 - 2 = 9.2
L7 = L9 - water surface = 9.2 - 15 = -5.8

Closed bucket = 5.8 units under water and 9.2 units above sea bed

 

klaus

Expert
Licensed User
Longtime User
Is this what you are looking for ?



Again, this is just a demonstrator project, tested only with B4J.

You can change the angle either with the seekbars or with the mouse clicking on the red dots.
 

Attachments

  • Excavator.zip
    26.9 KB · Views: 48

amorosik

Expert
Licensed User
Hinged figures, perfectly functioning zoom, and real-time measurement, for me it's exceptional
I don't understand where those 'end stops' of the various segments can be modified
A very special thanks for the help provided
 

klaus

Expert
Licensed User
Longtime User
I don't understand where those 'end stops' of the various segments can be modified
I suppose that you are speaking of the angle limits.
These are defined in the Initialize routine of the ExcavatorObject module.
 

klaus

Expert
Licensed User
Longtime User
I have played a bit further with this project.
In B4J, the zooming is done with the mouse wheel and the moving is done with the right mouse button.
In B4A, the zooming and moving is done with the fingers.
I have added an excavator, which shows the use of a bitmap for the buckle, it was another question.
I have modified a bit the layout for smartphones.



You can select Measure to make a measurement.
When it is unselected you can move either the crane or the excavator with red points.
 

Attachments

  • Crane.zip
    42.6 KB · Views: 38
Cookies are required to use this site. You must accept them to continue using the site. Learn more…