
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
I have a 18x12 linear grid with spot elevations at every intersection. I need to interpolate contour points on the given segments between spots. So the math its self is simple:
Let's say we have two spot elevations A & B. A = 69.4 and B = 71.4. The distance between A & B = 50 feet. We want to know where the 70 foot contour would fall between spot elevations A & B. First obtain the total elevation difference. This is done by subtracting A from B. 71.4 minus 69.4 = 2. Next we want the difference in elevation between our 70 contour interval and the nearest spot elevation which in this case is A or 69.4. That works out to be 0.6. Now we need to calculate the distance (let's call this "d") we need to go from spot elevation A to our 70 foot contour. That takes the form of: d=0.6*50/2 = 0.6*25 = 15 or the distance, in decimal feet, to our 70 foot contour. From there we would place a point 15 units from A and that is where the 70 foot contour point is on the line segment.
Due to it being a grid of 432ish segments, some having no points and others having up to 5, it is a very long a tedious process to do every segment. I have found different routines that do the job relatively but there is a part of them that does not work with what is needed(wrong contour interval, needs 3d points instead of 2d like I have, etc.). So I have been working on learning lisp while trying to create a routine to address my problem. I have made what logic I can from what I have gathered but I do not know how to get the routine to work. Below is what I came up with and below that is where I worked through the logic to verify it when I could.
a=69.4 b=71.4 dis=50 contour=70 71.4-69.4=2 70-69.4=0.6 d=0.6*50/2 d=0.6*25 d=15 (defun c:interp1 (/a b e f cont d) (setvar "PDMODE" 34) (setvar "PDSIZE" 5) (setq e (getpoint "\nPick Point 1: ")) (setq a (getreal "\nSpecify First Height: ")) (setq f (getpoint "\nPick Point 2: ")) (setq b (getreal "\nSpecify Second Height: ")) (setq cont (getreal "\nSpecify Contour Needed: ")) (setq d (*(/ (distance e f) (- b a)) (- cont a))) (setq g (polar (a) 0 d)); should return the UCS point needed (entmake ((0 "POINT") (10 g))) (princ)) (defun c:interp2 (/a b e f cont d) (setvar "PDMODE" 34) (setvar "PDSIZE" 5) (setq e = 521962 44395 (getpoint "\nPick Point 1: ")) (setq a = 69.4 (getreal "\nSpecify First Height: ")) (setq f = 521912 44395 (getpoint "\nPick Point 2: ")) (setq b = 71.4 (getreal "\nSpecify Second Height: ")) (setq cont = 70(getreal "\nSpecify Contour Needed: ")) (setq d (*(/ (distance 521962 44395 521912 44395) (- 71.4 69.4)) (- 70 69.4))) (setq d (*(/ (50) (2)) (0.6))) (setq d (*(25) (0.6))) (setq d (15) (setq g (polar (69.4) 0 15)); should return the UCS point needed (entmake ((0 "POINT") (10 521947 44395)));"521947 44395" is the correct answer, not sure if "g" returns this though... (princ))
It would be greatly appreciated if I could have some help getting the routine to work. I understand that there is going to be a better & cleaner way of doing it, and by all means anyone can share and I may use it. But I would also like the routine I wrote to work and an explanation on what was added/modified so I can learn from it rather than just getting a solution and not understanding it.
Thank you for your time,
Austin Casteel
Solved! Go to Solution.