Using an extrusion vector to find a point

Using an extrusion vector to find a point

Anonymous
Not applicable
1,273 Views
3 Replies
Message 1 of 4

Using an extrusion vector to find a point

Anonymous
Not applicable

Given a start point, a distance to travel, and an extrusion vector; how do I calculate the new point?

Is there a defined function to do this?  I am thinking of something like the polar function (polar PT ANG DIST) but using the extrusion vector in place of the 2d angle to find the point in 3d. Can anyone help with this?

0 Likes
Accepted solutions (1)
1,274 Views
3 Replies
Replies (3)
Message 2 of 4

phanaem
Collaborator
Collaborator

Multiply the vector (must be unit vector) with the distance and add to the origin.

(polar_3d origin vector d)

 

If the vector is not unit vector, use unit function below to transform it.

(polar_3d origin (unit vector) d)

 

The two polar_3d functions are similar. The second is just the first one expanded.

 

(setq origin (list 1 1 1)
      vector (list 0.534522 0.801784 0.267261)
      d 5.0)

(defun unit (v)
  (setq d (distance '(0 0 0) v))
  (mapcar '(lambda (a) (/ a d)) v)
)

(defun polar_3d (o v d)
  (mapcar '(lambda (a i) (+ a (* i d))) o v)
  )

(defun polar_3d (o v d)
  (list
    (+ (car   o) (* (car   v) d))
    (+ (cadr  o) (* (cadr  v) d))
    (+ (caddr o) (* (caddr v) d))
  )
)

 

 

Message 3 of 4

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

Given a start point, a distance to travel, and an extrusion vector; how do I calculate the new point?

Is there a defined function to do this?  I am thinking of something like the polar function (polar PT ANG DIST) but using the extrusion vector in place of the 2d angle to find the point in 3d. Can anyone help with this?


If it's something like the extrusion direction entry in entity data [the (assoc 210) entry], which is a unit vector, then the sum of the squares of the three coordinates is 1, and the "raw" point with those coordinates is 1 unit away from the 0,0,0 origin in the given direction.  So you should be able to multiply the coordinates of the unit vector by the distance you want to go, and add that resulting set of coordinates to your start point's coordinates.  If YourStartPoint and YourUnitVector are both three-coordinate XYZ point lists [with the 210 code identifier stripped off if you're getting it from an entity's extrusion direction], and YourDistanceToTravel is a real number, try something like this [untested]:

(mapcar

  '+

  YourStartPoint

  (mapcar '(lambda (x) (* x YourDistanceToTravel)) YourUnitVector)

)

 

If your extrusion vector is not a unit vector, compensation could be made easily enough.

Kent Cooper, AIA
Message 4 of 4

stevor
Collaborator
Collaborator

If you actually mean a displacement vector,

instead of an extrusion, then the analog of 'polar'

could be:  (vector_sum startpoint dissplacementvector)

 

(setq NewPt (V_Sum StartPt DispVec))


; Vector Sum
(defun v_sum (v1 v2 ) (mapcar '+ v1 v2 ) )

 

If you mean that you have a direction vector,

and a distance in that direction, then a bit more,

to make the 'displacement vector,'

like the others here said.

 

 

S
0 Likes