|
-
Apr 9th, 2001, 10:49 PM
#1
Thread Starter
Member
Hi,
I know the radius, start point, end point and the origin. By applying distance formula,
d = sqr((x1 - x2)^2 + (y1 - y2)^2)
I end up with 2 equations.
1.) distance between middle point and origin = radius,
2.) distance between start point and middle point = distance between end point and middle point
Therefore,
(x1,y1) = middle point
x2 = oArcGeom.Origin.X
y2 = oArcGeom.Origin.Y
x3 = oArcGeom.Start.X
y3 = oArcGeom.Start.Y
x4 = oArcGeom.End.X
y4 = oArcGeom.End.Y
1.) distance between middle point and origin = radius:
x1 ^ 2 - 2 * (x1 * x2) + x2 ^ 2 = oArcGeom.Radius - y1 ^ 2 + 2 * (y1 * y2) - y2 ^ 2
2.) distance between start point and middle point = distance between end point and middle point:
2 * (x1 * x4) - 2 * (x1 * x3) + x3 ^ 2 - x4 ^ 2 = 2 * (y1 * y3) - 2 * (y1 * y4) + y4 ^ 2 - y3 ^ 2
But I don't know how to simplify more, and VB cannot accept the above formula.
Can any one help me?
It take a baby step for you to be here, nothing is impossible.
v(^o^)v
-
Apr 12th, 2001, 03:47 PM
#2
Frenzied Member
Confused.
I am confused. I am not sure what variables are known and which are unknown.
What are you trying to determine or draw or whatever?
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Apr 12th, 2001, 03:57 PM
#3
Banned
[quote]
I know the radius, start point, end point and the origin.
[/b]
He wants to know the middle point of the arc.
-
Apr 12th, 2001, 05:10 PM
#4
Frenzied Member
Try polar coordinates.
It looks like you are trying to use simultaneous equations to solve this problem when trig is probably necessary.
My approach might be a long way around to get where you want to go, but I think it will work. It involves converting to and from polar coordinates.
I really do not want to go through the work of solving this, but can provide an algorithmic approach, which should be programmable.
I hope i understand the notation you are using. If not, let me know and I will try to post a corrected description of the following.
If circle is not centered at origin, do a coordinate transform which puts it there. This is accomplished by subtracting circle center coordinates from end point coordinates. In you original notation, this looks like- Newx3 = x3 - x2
- Newy3 = y3 - y2
- Newx4 = x4 - x2
- Newy4 = y4 - y2
If circle is centered on the origin, use (x3, y3) & (x4, y4) as is.
Now determine angles for polar instead of Cartesian coordinates.- AngleStart = Atn(Newy3 / Newx3)
- AngleEnd = Atn(Newy4 / Newx4)
- AngleMid = (AngleStart + AngleEnd) / 2
- Midx = R * cos(AngleMid)
- Midy = R * sin(AngleMid)
Now transform back to original coordinate system.- x1 = Midx + x2
- y1 = Midy + y2
The Atn Function probably cannot be used directly. I suggest writing a function which accepts XY-Coordinates as arguments and returns an angle from zero to 2*Pi (0 to 360 degrees). The function would use Atn internally. If you use the Atn function directly, there is a problem with an X-coordinate of zero being used a s a denominator. There is also a problem with points in the second and third quadrants (90 to 270 degrees) The Atn function always returns a value in the first or fourth quadrant (+90 to - 90 degrees.).
I posted a usable function somewhere. If you search the forum for ArkTangent you should find it.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Apr 12th, 2001, 07:19 PM
#5
Frenzied Member
ArkTangent
Excuse the spelling. In previous post I mentioned an ArkTangent Function which has been posted elsewhere.
I did a search and discovered it has been posted at least twice. Once with quadrant logic to return an angle between 0 and 2Pi (0 and 360 degrees), and once with no quadrant logic, returning an angle between zero and Pi/2 (0 and 90 degrees).
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Apr 12th, 2001, 09:00 PM
#6
Thread Starter
Member
err... it dun look likes working...
i compare the value with the one i should get, it is different. anyway, I wroted a rather dinosour procedure for it, and it work.
Code:
Function ReturnARCMiddleXY(startX As Double, startY As Double, endX As Double, endY As Double, originX As Double, _
originY As Double, Radius As Double) As Double()
Dim distanceX As Double
Dim distanceY As Double
Dim distanceT As Double
Dim PointXY(1) As Double
Dim PointMidStartEnd(1) As Double
PointMidStartEnd(0) = (startX + endX) / 2
PointMidStartEnd(1) = (startY + endY) / 2
If startX = endX Then
PointXY(1) = PointMidStartEnd(1)
If startX > originX Then
PointXY(0) = originX + Radius
Else
PointXY(0) = originX - Radius
End If
ElseIf startY = endY Then
PointXY(0) = PointMidStartEnd(0)
If startY > originY Then
PointXY(1) = originY + Radius
Else
PointXY(1) = originY - Radius
End If
'right side of origin
ElseIf PointMidStartEnd(0) > originX Then
distanceT = Sqr((PointMidStartEnd(0) - originX) ^ 2 + (PointMidStartEnd(1) - originY) ^ 2)
distanceX = Radius * (PointMidStartEnd(0) - originX) / distanceT
distanceY = Sqr(Radius ^ 2 - distanceX ^ 2)
PointXY(0) = originX + distanceX
If PointMidStartEnd(1) > originY Then
PointXY(1) = originY + distanceY
Else
PointXY(1) = originY - distanceY
End If
'left side of origin
ElseIf PointMidStartEnd(0) < originX Then
distanceT = Sqr((originX - PointMidStartEnd(0)) ^ 2 + (PointMidStartEnd(1) - originY) ^ 2)
distanceX = Radius * (originX - PointMidStartEnd(0)) / distanceT
distanceY = Sqr(Radius ^ 2 - distanceX ^ 2)
PointXY(0) = originX - distanceX
If PointMidStartEnd(1) > originY Then
PointXY(1) = originY + distanceY
Else
PointXY(1) = originY - distanceY
End If
End If
ReturnARCMiddleXY = PointXY()
End Function
BTW, thanks for ur response, GUV!
Last edited by engowen; Apr 12th, 2001 at 09:07 PM.
It take a baby step for you to be here, nothing is impossible.
v(^o^)v
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|