Author Topic: Triangulation  (Read 12836 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Triangulation
« Reply #15 on: February 10, 2006, 05:52:59 PM »
OK, I moved my triangle, same result using the 'test.lsp'. 8-)
p1 is no longer at 0,0,0

p1 (34.3598 13.5639 10.0)
p2 (44.3598 23.5639 20.0)
p3 (46.3598 16.5639 14.0)
p4 (39.8598 16.8139)

p1>p2p3 [2d] (45.3598 20.0639)
p1>p2p3 [3d] (45.3598 20.0639 17.0)

px  (39.8598 16.8139 13.5)

I could be missing something as I'm not a 3d guy. :)
I tested the test3.lsp in a rotated arouns z  UCS & it workd fine but did not test any other rotation.
« Last Edit: February 10, 2006, 05:57:01 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Serge J. Gianolla

  • Guest
Re: Triangulation
« Reply #16 on: February 10, 2006, 05:56:41 PM »
You keep working with the assumption that P4 is user-selected. If it is true then, isn't it easier to add the Z's for P1, P2 and P3 then average them:
(Z1+Z2+Z3)/3 then the obtained value is replacing Z4?

CarlB

  • Guest
Re: Triangulation
« Reply #17 on: February 10, 2006, 06:01:04 PM »
I didn't say p1 & p4 intersect.
Here is an explanation.

CAB, that's a nice illustration.  I think your theory is sound.  It doesn't matter that Pt1 is at 0,0,0 that is just to make it easier to follow - the math uses elevation differences anyway.  As long as you followed a sign convention it seems you should get the right answer.  And if it turns out that the z of the pick point is outside the range of the P1>Px line, then you could also tell whether the point falls inside the triangle.  Much easier to follow than the matrix math :)

I don't know about your line-plane intersection example, it may be correct but I think several steps/calculations are needed to go from a 3d face and a point to get those equations.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Triangulation
« Reply #18 on: February 10, 2006, 06:06:26 PM »
Serge
I don't see why the p4, picked or sent by another routine has any bearing but I'm not that good with 3d stuff.
The average z would only apply to the center of the triangle. Well maybe not called the center but where all
three bisector lines intersect. Otherwise the average z is not correct.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Serge J. Gianolla

  • Guest
Re: Triangulation
« Reply #19 on: February 10, 2006, 06:11:04 PM »
OOps
Quote
The average z would only apply to the center of the triangle.
  :oops:

Serge J. Gianolla

  • Guest
Re: Triangulation
« Reply #20 on: February 10, 2006, 06:17:58 PM »
Yes, it does matter if the pt is external to 3DFace. 1st case scenario, P1 P4 could be parallel to P2 P3 never intersecting. Even though if could be a fluke, it may happen. Another case is P4 anywhere outside the 3DFace when intersecting the lines the new point projected ends up to another 3DFace if we speak of a Triangular Irregular Network mesh, thereabout giving the wrong elevation.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Triangulation
« Reply #21 on: February 10, 2006, 08:15:42 PM »
After further testing, the routine only works if you rotate about the z axis.
Rotation about the x or y axis don't work. :-(
Perhaps that is what Serge was trying to tell me all along.
If the triangle was 5 feet in the air and you were 10 feet above that looking straight down then
any point on the ground would be in the triangle. But when you rotate the x and or y axis and you are
looking down but at an angle to the xy and the point you are looking at on the ground may not be under the
triangle relative to the z axis. Not sure if may description was accurate.
This is why I shy away from the 3d stuff.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Triangulation
« Reply #22 on: February 10, 2006, 08:24:05 PM »
You can see where he triangle projects into the xy pland along the z axis.
So "dropping" a point through what appears to be  the triangle will nit the xy plane outside the triangle.
« Last Edit: February 11, 2006, 09:31:18 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Triangulation
« Reply #23 on: February 10, 2006, 08:28:20 PM »
Another formula if anyone wants to take a crack at it.
http://astronomy.swin.edu.au/~pbourke/geometry/planeline/
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CarlB

  • Guest
Re: Triangulation
« Reply #24 on: February 11, 2006, 03:58:18 AM »
CAB,

I'm not sure why you say it "didn't work".  Your routine is designed to project a point onto a plane, projecting along the z axis.  So it won't appear to look right when your view isn't perpendicular to the z axis.  Your solution, I think, solved what the original poster was trying to do.  Iintersecting an arbitrary line with a plane is more complex and will require the matrix math solutions, then "point in polygon" algorithm to find whether the point-plane intersection is inside the polygon.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Triangulation
« Reply #25 on: February 11, 2006, 09:28:19 AM »
Thanks Carl.
It does work as long as you rotate only the z-axis.
I updated the picture. Not exactly accurate but represents the problem with other rotations.
Picking the magenta X will result in a z-axis projection outside the triangle. Yellow vector.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Triangulation
« Reply #26 on: February 11, 2006, 10:42:18 AM »
I don't believe the original posters stated intent is decisive enough to provide a solution.

Is the requirement to "use" the < perhaps twisted > view on the triangle as a "viewport" onto the current UCS. ?

If so,
because the problem is expressed using AutoCAD parameters, I see no problem using a Geometric solution, rather than a formulae.

OP feedback is required.



kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Serge J. Gianolla

  • Guest
Re: Triangulation
« Reply #27 on: February 13, 2006, 06:59:43 PM »
Still no news from original poster, so I shall assume that there is only one triangle and indeed the point is inside - no need to check for P4 validity.
In the old GeomCal there is the ilp function. Can be accessed in Topics AutoLISP Reference, in Cal as a header: Obtaining an intersection point

intersection of a line p1-p2 and a plane defined by p3-p4-p5

ilp(p1,p2,p3,p4,p5)

In our case the picked pt to find Z value would be p1 and P2 would be at any user-defined distance along Z axis, assuming or setting UCS as WCS.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Triangulation
« Reply #28 on: February 13, 2006, 07:08:04 PM »
Hi Serge,
Yes, I looked at the CAL ILP function too. It will work, given my understanding of the OP's post.
 .... but I've been wrong about interpretation before, so I held off posting a solution.

kwb
 
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Didge

  • Bull Frog
  • Posts: 211
Re: Triangulation
« Reply #29 on: February 14, 2006, 06:17:33 AM »
Sorry for the delay in responding Guys, I've spent a long weekend moving home and sadly no internet connection at the new place as yet.

I wasn't expecting such a detailed response, thank-you all very much.

As for CAB's input, what can I say except that I'm still trying to take it all in, not the easiest of tasks on a return to work - thank-you very much, but please let me sleep on some of those examples. (Beginning to think I've bitten-off more than I can chew :-)

Serge is almost correct, it's not quite draping but interpolating levels from a TIN. I've found a great triangulation lisp routine on the web, "Triangulate" written by DANIELE PIAZZA and based upon some C code by the same name, credited to PAUL BOURKE.

I've written a small lisp app that creates 3 dimensional pipe & chamber networks using ACAD's solid modelling. My employer's GIS record system provides the Pipe Invert Levels and diameters, I just need to interpolate the Chamber Cover Levels to complete a totally automatic system.

With regard to the P4 issue, it was my intention to create a (Get_Z) function that takes a numeric X,Y argument, then scans through a selection set of 3D Faces before returning an interpolated Z elevation for that X,Y point.

Hope that makes sense.

Didge.
Think Slow......