PDA

View Full Version : A little direction please...



pslge746922
2017-03-31, 04:06 PM
I apologize first, if my posting here offends anyone.

I am not an AUGI type (in fact, I do not know surveying, math, etc.). I was doing a search on 'Survey, curves, arc', and came across this posting on your forums...http://forums.augi.com/showthread.php?22985-Enter-survey-points-on-a-curve. It does look related to what I am looking for.

I am trying to take survey curve information, and (in a C# program), translate it to use in C# SkiaSharp DrawPath project. My posting here has not gotten any replies (SkiaSharp is fairly new, and there are no examples of what I am trying to do)... https://forums.xamarin.com/discussion/90526/how-to-add-survey-curve-info-to-my-drawpath-image#latest.

I am trying to convert the survey curve information to what the ArcTo method...https://developer.xamarin.com/api/member/SkiaSharp.SKPath.ArcTo/p/SkiaSharp.SKRect/System.Single/System.Single/System.Boolean/, is looking for..." public Void ArcTo (SKRect oval, Single startAngle, Single sweepAngle, Boolean forceMoveTo) "

oval The bounding oval defining the shape and size of the arc.
startAngle The starting angle (in degrees) where the arc begins.
sweepAngle The sweep angle (in degrees) measured clockwise.
forceMoveTo Whether to always begin a new contour with the arc.

I do not have the foggiest idea of what values from the survey curve info to use to create what is required for each of the method parameters, or how to create that info.

Even if it is just pointing me else (telling me where to go...figuratively :)), I would appreciate it.

CAtDiva
2017-03-31, 04:56 PM
Thread moved for better responses.

remi678731
2017-03-31, 09:00 PM
what type of curve are you working with it sounds like a spiral which is considerably more complex

CAtDiva
2017-03-31, 11:08 PM
Someone suggested this might be better in a programming sub-forum. If another mod knows of a better place, feel free to relocate it.

pslge746922
2017-04-02, 11:44 AM
remi678731


What type of curve...I don't know (not being a survey\math type). Using the info on that survey, that I posted, someone else came up with this, but did not replace the w, C D, etc., with the survey info...


abs(W) = L / R
(A + W) modulo 2pi ≡ arctangent((Ey-Cy) / (Ex-Cx));

Use both equations to get the right value for W.

So it looks like you have or can calculate:

S = starting point of the arc.
E = ending point of the arc,
R = radius of the arc (so it must be a section of circle)
L = arc length.

Skia needs C, the center of the circle that the arc is part of. From the definintion of a circle:

distance(C, S) = R
distance(C, E) = R

(Cx-Sx)^2 + (Cy-Sy)^2 = R^2
(Cx-Ex)^2 + (Cy-Ey)^2 = R^2


Solve for C = {Cx,Cy}. Throw one answer away.

Skia also needs the start angle A and the sweep W.

A = arctangent((Sy-Cy) / (Sx-Cx)) ;
W = arctangent((Ey-Cy) / (Ex-Cx)) - A;

The bounding rectangle of the circle is {Cx-R,Cy-R,Cx+R,Cy+R}

SkPath path;

path.arcTo({Cx-R,Cy-R,Cx+R,Cy+R}, radian2degree(A), radian2degree(W), false);

seant61
2017-04-05, 11:39 AM
Is there some reason to use the:
public Void ArcTo (SKRect oval, Single startAngle, Single sweepAngle, Boolean forceMoveTo)

overload for the AddArc Method?

It seems that the Curve Info table gives you enough to find both the startpoint (via endpoint of previous line) and endpoint (via chord length and bearing) of the arc as well as the radius. Couldn't the overload:
public Void ArcTo (SKPoint point1, SKPoint point2, Single radius)

be used?

pslge746922
2017-04-05, 06:18 PM
Thanks for replying.

I am not a graphics\GIS type, so all this is fairly new to me. I do not know what to take from the curve info table, what formula to use to get the values needed for the method calls, let alone which of the overrides to use.

You are saying to use the 'ArcTo (SKPoint point1, SKPoint point2, Single radius)', which is more then I knew, but I unclear on what values to use.

endpoint of previous line - the last point\straight line, in the drawline ?
endpoint (via chord length and bearing) of the arc = ?
radius = ?

seant61
2017-04-05, 10:06 PM
Let me first say that I have no experience whatsoever with SkiaSharp. The method call look similar to both XAML and AutoCAD’s.

In one of the links you said “ I can take a survey map line, like ‘N 06 27 11 E’ 488.27, and can come up with 54.87623 -485.1765”.
I take that to mean you can project a bearing and distance from your current position(position as an SKPoint, perhaps).

That’s good because the Curve Info Table includes data describing the arc’s chord (A chord is the straight line between the two endpoints of an arc)
So if you processed the Chord Bearing and Chord Length from the Curve Info Table(the same way you were able to derive 54.87623 -485.1765) you could use the current position’s SKPoint.Offset method. For example using N 06 27 11 E :
SKPoint arcEndpoint = CurrentPosition.Offset(54.87623 -485.1765)

Those two points, as well as the appropriate radius, may then be used with :
public Void ArcTo (SKPoint point1, SKPoint point2, Single radius)

So the theory goes.

pslge746922
2017-04-13, 07:26 PM
I have been trying to understand your instructions, made some progress, but not enough.

There are 9 coordinates...
54.87623 -485.1765, 1
179.7689 -507.0286, 2 C1
65.13455 -501.0532, 3
89.57177 -528.5947, 4 C2
37.36042 -1038.036, 5
88.97673 -1027.655, 6 L1
160.4506 -1012.855, 7
196.4012 -1004.363, 8 L2
358.8415 -965.3903 9

Property layout...
105035

This is the C# SkiaSharp code. I have the x,y coordinates (above) in two separate arrays...

using (var path = new SKPath())
{
path.MoveTo(MyGlobals.strX[0], MyGlobals.strY[0]); // [0]
for (int i = 1; i < MyGlobals.strX.Length; i++) // [1] +
{
if (i == 1)
{
//SKPoint SkPoint1 = new SKPoint(MyGlobals.strX[0], MyGlobals.strY[0]);
SKPoint SkPoint2 = new SKPoint(MyGlobals.strX[1], MyGlobals.strY[1]); //curve
SKPoint SkPoint3 = new SKPoint(MyGlobals.strX[0], MyGlobals.strY[0]); //create 0 again for use with offset
SkPoint3.Offset(SkPoint2); //x=234.6451 y=-992.2051
//path.ArcTo(SkPoint1, SkPoint3, 335);
path.ArcTo(SkPoint2, SkPoint3, 335);
continue;
}
if (i == 3)
{
//SKPoint SkPoint1 = new SKPoint(MyGlobals.strX[2], MyGlobals.strY[2]);
SKPoint SkPoint2 = new SKPoint(MyGlobals.strX[3], MyGlobals.strY[3]); //curve
SKPoint SkPoint3 = new SKPoint(MyGlobals.strX[2], MyGlobals.strY[2]); //create 2 again for use with offset
SkPoint3.Offset(SkPoint2); //x=154.7063 y=-1029.648
//path.ArcTo(SkPoint1, SkPoint3, 25);
path.ArcTo(SkPoint2, SkPoint3, 25);
continue;
}

path.LineTo(MyGlobals.strX[i], MyGlobals.strY[i]);
}


path.Close();

And this is the SkiaSharp DrawPath draws...
105036

Obviously I am not doing this correctly. I am getting curves, but it looks nothing like the other attached property image.

seant61
2017-04-14, 04:40 PM
To generate the number of direction vectors , there seems to be a missing coordinate in you listing above. Presumably it is MyGlobals.StrX[0], MyGlobals,strY[0]. Based on what I see in AutoCAD, I’d say it is around 350, -975.

Perhaps, for the time being, we just limit the task to generating straight lines (i.e., the chord line for the arcs) even it’s just to help me visualize that general process with SkiaSharp.

The attached PDF shows what happens when I import those coordinates into AutoCAD, and possible fixes for the demonstrated issues. Augi is not letting me upload files at this time.:cry:

Is it possible that there is a glitch in the algorithm that converts Direction and Magnitude into coordinates?

pslge746922
2017-04-14, 05:55 PM
Before I start making changes to do just straight lines, I ran again, and when done creating the path, I looked at the path.points (before it did the actual drawing). I started with 9, and now there are 13. These extra points are being put in by the two ArcTo lines indicated by'C1' and 'C2'. The added coordinates are indicated by '**'...

54.87623 -485.1765, 1
-67.19397, -463.8181 **
179.7689 -507.0286, 2 C1
207.9465, -756.1548 **
65.13455 -501.0532, 3
84.47117 -522.8462 **
89.57177 -528.5947, 4 C2
90.56247, -536.2158 **
37.36042 -1038.036, 5
88.97673 -1027.655, 6 L1
160.4506 -1012.855, 7
196.4012 -1004.363, 8 L2
358.8415 -965.3903 9

pslge746922
2017-04-14, 06:40 PM
Ok, using the same 9 coordinates as above (which include the two Chord lines), but without doing the ArcTo (curves) code, this is what the drawing looks like...
105041

To give you a better idea of how the lines look without the curves...
Now, eliminating the two chord lines, and extending (guestimates), lines 3 and 5 above (except for the first line, all the other line coordinates were subsequently changed)...
54.87623 -485.1765,
-164.6158 -473.7353, - eliminated #2 above and extended # 3 by 105 ft
-218.8662 -1003.073, - eliminated # 4 above and extended # 5 by 15 ft
-167.2499 -992.6909,
-95.77599 -977.8915,
-59.82541 -969.3992,
102.6149 -930.4265

And this is what the drawing looks like now...
105042

seant61
2017-04-15, 12:03 AM
The image SkiaSharpImage2.PNG is showing real promise, and has features demonstrating a relationship to Property.PNG in post #9 of this thread.

I think part of the discrepancy is how screen coordinates work with Skia - similar to XAML - which is that positive Y values work down the screen. In most CAD applications positive Y progresses up the screen.
I also think that the Northern-Eastern to screen coordinate translation mishap has made Coordinate 1 (54.87623 -485.1765) out of sorts with the remainder, and that's why there is that crossover in the property layout.

Re-examine the coordinate generating code with that Up/Down discrepancy in mind. Maybe something will turn up.

pslge746922
2017-04-15, 03:58 PM
Figured out how to show better image of the land...
105045

I am wondering if using coordinate # 1 (the bottom line of the property, pointing to the road), as one of the points in the ArcTo, was wrong. So, I took the line from the property underneath (along the road (232.85 ft), and am using that as the one of the points in the Arcto, (0.0005950928f, 0.009246826f)...

if (i == 1)
{
SKPoint SkPoint1 = new SKPoint(0.0005950928f, 0.009246826f);
SKPoint SkPoint2 = new SKPoint(MyGlobals.strX[1], MyGlobals.strY[1]); //curve
//SKPoint SkPoint3 = new SKPoint(MyGlobals.strX[0], MyGlobals.strY[0]); //create 0 again for use with offset
SkPoint1.Offset(SkPoint2); //x=234.6451 y=-992.2051
//SkPoint3.Offset(SkPoint2); //x=234.6451 y=-992.2051
//path.ArcTo(SkPoint1, SkPoint3, 335);
path.ArcTo(SkPoint2, SkPoint1, 335);
continue;
}

I have tried it two ways, first using path.ArcTo(SkPoint1, SkPoint2, 335);...
105046

Then path.ArcTo(SkPoint2, SkPoint1, 335);...
105047

Not knowing this stuff, I am really not sure what is going on here.