Forum Groups
  All forums
    Help & Feedback
      Work in progress
      Finished Art
      Non-Max related

Featured Threads
  inspiration alert!!!
(37 replies)
  Indespensible MaxScripts, Plugins and 3rd Party Tools
(37 replies)
  The allmighty FREE Resources Thread !
(17 replies)
  spam alert!!!
(4886 replies)
  Maxforums member photo gallery index
(114 replies)
  Maxforums Member Tutorials
(89 replies)
  three cheers to maxforums...
(240 replies)
  101 Things you didnt know in Max...
(198 replies)
  A Face tutorial from MDB101 :D
(95 replies) Members Gallery
(516 replies)
(637 replies)
  Dub's Maxscript Tutorial Index
(119 replies)

Maxunderground news unavailable

Trigonometry script help
show user profile  3joez
I would like to infere the coordinates of the intersecting point of the two lines.
I can calculate the angle via dotproduct but I'm stuck on how to get the pivot point of that angle. Here's the pic

read 572 times
12/2/2014 10:00:45 AM (last edit: 12/2/2014 10:00:45 AM)
show user profile  Garp

read 560 times
12/2/2014 1:04:37 PM (last edit: 12/2/2014 1:04:37 PM)
show user profile  3joez

read 549 times
12/2/2014 3:05:20 PM (last edit: 12/2/2014 3:05:20 PM)
show user profile  Garp
I don't mean to be rude but.. did you search?
What I meant was that the question has been asked and answered, like, a million times all over the web.

read 540 times
12/2/2014 4:29:15 PM (last edit: 12/2/2014 4:29:15 PM)
show user profile  3joez
Yes. I'm still trying to figure that out. I don't find it easy, that's all. I should have mentioned that I'm trying to solve the problem in 2d space (from top view,for example).

So, from what I'm figuring out, the basic steps should be these (in pseudo code)

Given the two lines

LineA (ax,ay) (bx,by)

LineB (cx,cy) (dx,dy)

1. Get the direction vectors of the two lines
vec1 = (bx-ax), (by-ay)
vec2 = (dx-cx), (dy-cy)

2. Generate a new vector from the previous two (I'm not sure about this) by subtracting them.
vec3 = vec2 - vec1

3. Stuck here. And I don't even know if I'm on the right track.

Here, more practically, I'm trying to implement this.

read 536 times
12/2/2014 4:43:41 PM (last edit: 12/2/2014 5:11:18 PM)
show user profile  Nik Clark
Lol, when answers on the net give you equations like this:

I still need help! :D

read 516 times
12/2/2014 5:22:17 PM (last edit: 12/2/2014 5:22:17 PM)
show user profile  Garp

The code in mxs is pretty much a copy-paste.

read 510 times
12/2/2014 5:50:24 PM (last edit: 12/2/2014 5:50:24 PM)
show user profile  3joez
Since I want to understand and not just merely copy, I'll start to share some insights, as long as they become clearer.


Two line segments can be expressed, in 2d euclidean space, with the regular formula
y = mx + b

For our purpose, we shall introduce in the formula two unknown points Ua and Ub

So the line now can be expressed with

L1 = firstPoint + Ua (secondPoint-firstPoint)
L2 = thirdPoint + Ub (fourthPoint-thirdPoint)

The point of intersection happens when those two equations are equal, so

firstPoint + Ua (secondPoint-firstPoint) = thirdPoint + Ub (fourthPoint-secondPoint)

firstPoint means x1(the x of the first point, first line)
secondPoint means y1(the y of the first point, first line)
thirdPoint means x2(the x of the second point, first line)
and so forth

Isolating the unknown points you should have this

Which should give you the coordinates of the intersection.

Now, I don't know why somebody was using cross product. But this lead me to somewhere. It shouldn't be hard to translate into mxs.

At the end you should plug back the Ua and Ub into the equations

L1 = firstPoint + Ua (secondPoint-firstPoint)
L2 = thirdPoint + Ub (fourthPoint-thirdPoint)

Double edit

After some research, this looks like an algorythm to find the intersection point of two lines that are already intersecting. So, I'll start from scratch.
Here, insert the owl gif back again.

read 483 times
12/3/2014 4:56:07 PM (last edit: 12/3/2014 5:18:05 PM)
show user profile  Garp
The form y = ax + b doesn't allow for vertical lines (parallel to the Y axis). ax + by = c should be preferred.

Once you have the two equations
ax + by = c
dx + ey = f

the first thing to check is that ae - db is not zero. If it is, it means that the lines have the same slope (they're parallel). In which case, either there is no intersection point, or there are an infinity of them.

read 472 times
12/3/2014 5:47:29 PM (last edit: 12/3/2014 5:48:11 PM)
#Maxforums IRC
Open chat window