Notifications
Clear all

[Closed] Math help finding position

How can I find the position point for the two green dots marked in the image below.

Here is the maxscript code that generates the test scene. I’ve been trying to figure out a good solution to this and I’ve a bit stumped. Hope someone can shed some light on the situation and help.

Thanks


delete objects
startPoint = [3.0,5.196,0.0]
endPoint = [0.0,12.0,0.0]
orgPointA = [0,10.5,0]
orgPointB= [0,8,0]

point pos:startPoint size:.5 wirecolor:yellow
point pos:endPoint size:.5 wirecolor:yellow
Arc radius:orgPointA.y from:0 to:90 pie:off reverse:off pos:[0,0,0] wirecolor:red
Arc radius:orgPointB.y from:0 to:90 pie:off reverse:off pos:[0,0,0] wirecolor:red
sp = splineshape wirecolor:red
spIndex = addNewSpline sp
addKnot sp spIndex #smooth #curve startPoint
addKnot sp spIndex #smooth #curve endPoint
updateshape sp
orgPtA = point pos:orgPointA size:.5 wirecolor:Green
orgPtB = point pos:orgPointB size:.5 wirecolor:Green


12 Replies

The problem is your arc. To find the position of intersecting lines is not hard i.e. two vectors. I was never great at maths but this guy is…

http://www.illusioncatalyst.com/3dsmax_files/snippets/geometry.php

If it’s always a similar case (all in 2D and center of arcs at [0,0]), it’s quite easy.

1- Find the ecuation of the line given by 2 points (A=startpoint and B=endpoint). You will get something similar to: y = mx + p where m=(yB-yA)/(xB-xA) and p =((yB-yA)*xA + (xB-xA)*yA) / (xB-xA) (check it please, I’ve done it quickly)
2- Find in this line the point (in fact, 2 points) that meets: x^2 + y^2 = R^2 where R is the radius of the archs

x^2 + (mx + p)^2 = R^2 => (m+1).x^2 + 2mp.x + (R^2-p^2) = 0 is the second degree ecuation to solve for both values of R.

If center of archs is not at [0,0], you have to translate your points coords a & B to the new center (x’A = xA-xO, y’A = yA – yO …)

2 Replies
(@jokermartini)
Joined: 11 months ago

Posts: 0

It’s always going to be at 0,0,0 and in 2D space!

(@aaandres)
Joined: 11 months ago

Posts: 0

Then you’ve got it!
Discard solutions with negative values of y.

Note: I understand you haven’t problems to solve a second degree ecuation.

I know how to calculate the angle from the top point using asin


hypot = distance endPoint startPoint
acuteAngle = asin(startPoint.x / hypot)

so this angle is 23.7935

Would you be able to modify your example to demonstrate it with my code. please?

Just change values!

xA = startpoint.x
yA = startpoint.y
xB = endpoint.x
yB = endpoint.y
R1 = orgPointA.y
R2 = orgPointB.y

General formula for 2nd degree ecuation: a.x^2 + b.x + c = 0
2 solutions:
x1 = (-b + sqrt(b^2-4ac)) / (2a)
x2 = (-b – sqrt(b^2-4ac)) / (2a)

Then you find y1 for x1 with the line ecuation and y2 for x2 identicaly. Discard negative values of y.
And that for the two radius R1 and R2.

I’ve updated the code but im not entirely clear how to use it. This is what i have so far, a few questions…


startpoint = [3.0,5.196,0.0]
endpoint = [0.0,12.0,0.0]
orgPointA = [0,10.5,0]
orgPointB = [0,10.5,0]

xA = startpoint.x
yA = startpoint.y
xB = endpoint.x
yB = endpoint.y
R1 = orgPointA.y -- What are these values? The origin or the radius?
R2 = orgPointB.y -- What are these values? The origin or the radius?

--y = mx + p
m=(yB-yA)/(xB-xA) 
p =((yB-yA)*xA + (xB-xA)*yA) / (xB-xA)

What do i do next then?
1- y = mx + p? what is y and x?
2- Find in this line the point (in fact, 2 points) that meets: x^2 + y^2 = R^2 where R is the radius of the archs
x^2 + (mx + p)^2 = R^2 => (m+1).x^2 + 2mp.x + (R^2-p^2) = 0 is the second degree ecuation to solve for both values of R.

Not sure i understand this step.

1.- x & y are the coords of any point in your line. We are going to find 2 points [x,y] that belong to the line and to the arc.

2.- (m+1).x^2 + 2mp.x + (R^2-p^2) = 0 : perfect. This is the ecuation that will give to you the two values of x of the 2 points that belong to the arc with the radius==R.
Then, start for example with the first arc: R = R1

You have a 2nd degree ecuation of type a.x^2 + b.x + c = 0 where:
a = (m+1)
b = (2.m.p)
c = (R1^2-p^2)

Find the two values of x with the formulas:
x1 = (-b + sqrt(b^2-4ac)) / (2a)
x2 = (-b – sqrt(b^2-4ac)) / (2a)

then:
y1 = m.x1 + p
y2 = m.x2 + p

And thus you have the two points [x1,y1] and [x2,y2] of the intersection of the line with the arc of radius R1.

Then, do the same for R=R2.

Check out these links:

http://www.albany.edu/faculty/jmower/geog/gog692/scans/Chapter3.pdf

http://mathworld.wolfram.com/Circle-LineIntersection.html …the formulas in this link assume the circles are always at origin– but you could re-derive to allow other offset (a,b) centers [i.e., (x-a)^2 + (y-b)^2 = R^2 ]

http://stackoverflow.com/questions/30006155/calculate-intersect-point-between-arc-and-line

Edit: Use the discriminant in second link to check if your line even intersects the arc or if it is only a single point intersection (i.e., tangent to the arc).

Did you get it, John?

Page 1 / 2