Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

BoundingBox at angle

17 REPLIES 17
Reply
Message 1 of 18
Anonymous
469 Views, 17 Replies

BoundingBox at angle

I have the boundingbox for an object but I am trying to get the boundingbox
at a specific angle. I thought that rotating the ucs I may get the desired
bounding box but that resulting in the boundingbox at World coordinates.

Does anyone have a way to get a boundingbox of an object but from a
reference angle.

--
|
-+-------------------------------------------------
| Rob Starz
| Stardsign cad solutions
| iC - AEC Information Center
| www.stardsign.com/aecic.html
| free ADT and Building Systems tools
| *******LayerX available Now*************
| www.stardsign.com/layerx.htm
| Easter Egg Hunt.....win a free version of LayerX
17 REPLIES 17
Message 2 of 18
Anonymous
in reply to: Anonymous

I am looking into Translatecoordinate. Am I headed in the right direction?

--
|
-+-------------------------------------------------
| Rob Starz
| Stardsign cad solutions
| iC - AEC Information Center
| www.stardsign.com/aecic.html
| free ADT and Building Systems tools
| *******LayerX available Now*************
| www.stardsign.com/layerx.htm
| Easter Egg Hunt.....win a free version of LayerX
"Rob Starz" wrote in message
news:660A80C4C50531EF7DCD4014D6D2D077@in.WebX.maYIadrTaRb...
> I have the boundingbox for an object but I am trying to get the
boundingbox
> at a specific angle. I thought that rotating the ucs I may get the
desired
> bounding box but that resulting in the boundingbox at World coordinates.
>
> Does anyone have a way to get a boundingbox of an object but from a
> reference angle.
>
> --
> |
> -+-------------------------------------------------
> | Rob Starz
> | Stardsign cad solutions
> | iC - AEC Information Center
> | www.stardsign.com/aecic.html
> | free ADT and Building Systems tools
> | *******LayerX available Now*************
> | www.stardsign.com/layerx.htm
> | Easter Egg Hunt.....win a free version of LayerX
>
>
Message 3 of 18
Anonymous
in reply to: Anonymous

Nope...I am still lost. Any input would be appreciated.

Thanks

--
|
-+-------------------------------------------------
| Rob Starz
| Stardsign cad solutions
| iC - AEC Information Center
| www.stardsign.com/aecic.html
| free ADT and Building Systems tools
| *******LayerX available Now*************
| www.stardsign.com/layerx.htm
| Easter Egg Hunt.....win a free version of LayerX
Message 4 of 18
Anonymous
in reply to: Anonymous

Perhaps (temporarily)rotating the object gives you the solution?

"Rob Starz" wrote in message
news:5671797EB607638939C31199EBCF131E@in.WebX.maYIadrTaRb...
> Nope...I am still lost. Any input would be appreciated.
>
> Thanks
>
> --
> |
> -+-------------------------------------------------
> | Rob Starz
> | Stardsign cad solutions
> | iC - AEC Information Center
> | www.stardsign.com/aecic.html
> | free ADT and Building Systems tools
> | *******LayerX available Now*************
> | www.stardsign.com/layerx.htm
> | Easter Egg Hunt.....win a free version of LayerX
>
>
Message 5 of 18
Anonymous
in reply to: Anonymous

I am working with using VLa-Copy and Rotate. I was just wondering if there
was a way to get this via a translation of points or something.

thanks

--
|
-+-------------------------------------------------
| Rob Starz
| Stardsign cad solutions
| iC - AEC Information Center
| www.stardsign.com/aecic.html
| free ADT and Building Systems tools
| *******LayerX available Now*************
| www.stardsign.com/layerx.htm
| Easter Egg Hunt.....win a free version of LayerX
Message 6 of 18
Anonymous
in reply to: Anonymous

I _believe_ that is the only way. BoundingBox returns the bounds in WCS of
the objects disregarding rotations or UCS's. Then along came "someone who
really knows"...

--
R. Robert Bell, MCSE
http://www.acadx.com


"Rob Starz" wrote in message
news:DFD08DEAE0A2AC80509721C090A61B0E@in.WebX.maYIadrTaRb...
| I am working with using VLa-Copy and Rotate. I was just wondering if
there
| was a way to get this via a translation of points or something.
|
Message 7 of 18
Anonymous
in reply to: Anonymous

Rotating the object doesn't give you a rotated bounding box, just a
distorted one.

--
http://www.acadx.com

Good judgement comes from experience.
Experience comes from bad judgement.


"Rob Starz" wrote in message
news:DFD08DEAE0A2AC80509721C090A61B0E@in.WebX.maYIadrTaRb...
> I am working with using VLa-Copy and Rotate. I was just wondering if
there
> was a way to get this via a translation of points or something.
>
> thanks
>
> --
> |
> -+-------------------------------------------------
> | Rob Starz
> | Stardsign cad solutions
> | iC - AEC Information Center
> | www.stardsign.com/aecic.html
> | free ADT and Building Systems tools
> | *******LayerX available Now*************
> | www.stardsign.com/layerx.htm
> | Easter Egg Hunt.....win a free version of LayerX
>
>
Message 8 of 18
Anonymous
in reply to: Anonymous

Actually I would need to rotate the object the negative value of the roation
angle I want. Then grab the boundingbox. I have that so far....now I am
trying to figure how to translate the poinst I got as compair to the
origianl location.

I hope I am explaining what I am looking for properly. I am no Geometry
whiz...so please forgive me.

thanks

--
|
-+-------------------------------------------------
| Rob Starz
| Stardsign cad solutions
| iC - AEC Information Center
| www.stardsign.com/aecic.html
| free ADT and Building Systems tools
| *******LayerX available Now*************
| www.stardsign.com/layerx.htm
| Easter Egg Hunt.....win a free version of LayerX
Message 9 of 18
Anonymous
in reply to: Anonymous

Here's an absolute hack:

Draw a rectangle using the bounding box coordiantes of the rotated copy,
then rotate the box back to the original angle.

--
http://www.acadx.com

Good judgement comes from experience.
Experience comes from bad judgement.


"Rob Starz" wrote in message
news:BC075D4C94253261EACBE7857880A5D8@in.WebX.maYIadrTaRb...
> Actually I would need to rotate the object the negative value of the
roation
> angle I want. Then grab the boundingbox. I have that so far....now I am
> trying to figure how to translate the poinst I got as compair to the
> origianl location.
>
> I hope I am explaining what I am looking for properly. I am no Geometry
> whiz...so please forgive me.
>
> thanks
Message 10 of 18
Anonymous
in reply to: Anonymous

Rob,

Here is something that might help you (I don't know, I must have something
on this I will search on my functions, not sure)

But in the meantime here is (just excuse my English and bad explanation I
not a good teacher):

To obtain what you are looking for you need to use the coordinates
transformation formula
in example: if you rotate the coordinate axis to a 15 degree angle
counterclockwise your point
(x,y) and the new coordinates

(x', y') according to the rotated axis will be:

x' = x * cos(A) + y * sin(A)
y' = y * cos(A) - x * sin(A)

Now, you need to take the first rotated point as reference to establish the
new
minimum and maximum coordinates and compare with the following points.
If a new point exists with an less x' than the previous point, then that
must be
the new minimum x, the same will be to find ymin', ymax', xmax'.
Right after to compare all the points you will obtain all the coordinates of
the
rectangle (boundingbox) corner rotated (xmin', ymin') and (xmax', ymax').
The four corners coordinates respect to the rotated axis then will be:

(xmin', ymin')
(xmax', ymin')
(xmax', ymax')
(xmin', ymax')

To transform this rotated coordinates respect to the normal coordinate
system
XY you must apply the following formula:

x = x' * cos(A) - y' * sin(A)
y = x' * sin(A) + y' * cos(A)
Message 11 of 18
Anonymous
in reply to: Anonymous

Luis,

This is a lot to ponder. I will print out and read over lunch and see if I
fully understand your procedure. I will need to draw pretty pictures to
understand this I think.

Thanks.

--
|
-+-------------------------------------------------
| Rob Starz
| Stardsign cad solutions
| iC - AEC Information Center
| www.stardsign.com/aecic.html
| free ADT and Building Systems tools
| *******LayerX available Now*************
| www.stardsign.com/layerx.htm
| Easter Egg Hunt.....win a free version of LayerX
"Luis Esquivel" wrote in message
news:843D3ADDB21A96CD79E46D25E52B4CC4@in.WebX.maYIadrTaRb...
> Rob,
>
> Here is something that might help you (I don't know, I must have
something
> on this I will search on my functions, not sure)
>
> But in the meantime here is (just excuse my English and bad explanation I
> not a good teacher):
>
> To obtain what you are looking for you need to use the coordinates
> transformation formula
> in example: if you rotate the coordinate axis to a 15 degree angle
> counterclockwise your point
> (x,y) and the new coordinates
>
> (x', y') according to the rotated axis will be:
>
> x' = x * cos(A) + y * sin(A)
> y' = y * cos(A) - x * sin(A)
>
> Now, you need to take the first rotated point as reference to establish
the
> new
> minimum and maximum coordinates and compare with the following points.
> If a new point exists with an less x' than the previous point, then that
> must be
> the new minimum x, the same will be to find ymin', ymax', xmax'.
> Right after to compare all the points you will obtain all the coordinates
of
> the
> rectangle (boundingbox) corner rotated (xmin', ymin') and (xmax', ymax').
> The four corners coordinates respect to the rotated axis then will be:
>
> (xmin', ymin')
> (xmax', ymin')
> (xmax', ymax')
> (xmin', ymax')
>
> To transform this rotated coordinates respect to the normal coordinate
> system
> XY you must apply the following formula:
>
> x = x' * cos(A) - y' * sin(A)
> y = x' * sin(A) + y' * cos(A)
>
>
>
Message 12 of 18
Anonymous
in reply to: Anonymous

Here are some Transformation Routines, that might be useful...

Best regards,
Luis Esquivel
Message 13 of 18
Anonymous
in reply to: Anonymous

Luis:

The problem remains that the bounding box retrieves the max/min x and y
based on the object's current orientation. In this crude pictogram, the
bounding box (shown as ......) is not at all the same shape or size as the
object (shown as * * * *) would be if rotated otherwise. As Frank says, I
believe "hacking" is in order.
............................
. * .
. * * .
. * * .
.* *
. * *
. * * .
..................*........

--
John Uhden, Cadlantic/formerly CADvantage
--> mailto:juhden@cadlantic.com
--> http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
FAX 732-528-1332

"Luis Esquivel" wrote in message
news:843D3ADDB21A96CD79E46D25E52B4CC4@in.WebX.maYIadrTaRb...
> Rob,
>
> Here is something that might help you (I don't know, I must have
something
> on this I will search on my functions, not sure)
>
> But in the meantime here is (just excuse my English and bad explanation I
> not a good teacher):
>
> To obtain what you are looking for you need to use the coordinates
> transformation formula
> in example: if you rotate the coordinate axis to a 15 degree angle
> counterclockwise your point
> (x,y) and the new coordinates
>
> (x', y') according to the rotated axis will be:
>
> x' = x * cos(A) + y * sin(A)
> y' = y * cos(A) - x * sin(A)
>
> Now, you need to take the first rotated point as reference to establish
the
> new
> minimum and maximum coordinates and compare with the following points.
> If a new point exists with an less x' than the previous point, then that
> must be
> the new minimum x, the same will be to find ymin', ymax', xmax'.
> Right after to compare all the points you will obtain all the coordinates
of
> the
> rectangle (boundingbox) corner rotated (xmin', ymin') and (xmax', ymax').
> The four corners coordinates respect to the rotated axis then will be:
>
> (xmin', ymin')
> (xmax', ymin')
> (xmax', ymax')
> (xmin', ymax')
>
> To transform this rotated coordinates respect to the normal coordinate
> system
> XY you must apply the following formula:
>
> x = x' * cos(A) - y' * sin(A)
> y = x' * sin(A) + y' * cos(A)
>
>
>
Message 14 of 18
Anonymous
in reply to: Anonymous

John

> The problem remains that the bounding box retrieves the max/min x and y
> based on the object's current orientation. In this crude pictogram, the
> bounding box (shown as ......) is not at all the same shape or size as the
> object (shown as * * * *) would be if rotated otherwise. As Frank says, I
> believe "hacking" is in order.
> ............................
> . * .
> . * * .
> . * * .
> .* *
> . * *
> . * * .
> ..................*........

Yes, but what I'm referring in my example formula is to do it without the
getboundingbox method, just by using some math's, I'm still searching for
that piece of code that I wrote some years back, and it does what Rob wants.

Later,
Luis
Message 15 of 18
Anonymous
in reply to: Anonymous

Ok Rob,

Here's my stab. This is overkill for a simple 2d rotation, but it's all
that I've currently got in my library. Feed each point of your boundingbox
to the (TransFormBy) function with the appropriate rotation angle in radians
& the rotation basepoint. The offsetXYZ arg will be '(0 0 0), unless you
want to move the box and the scaleXYZ arg will be '(1 1 1), unless you want
to scale it. Also note that this function is not optimized for speed, it is
optimized for me understanding the math behind the code. This won't matter
when calling it with four points of a bounding box, but if you're
transforming all the vertices of your 55,000 face 3dmesh imortalizing Rocky
& Bullwinkle, then it will matter.

;;;Special thanks to Vladimir Nesterovsky
;;;for these four matrix manipulation routines

;;;a dot product of the two vectors, u & v
(defun dotprod (u v)
(apply '+ (mapcar '* u v))
)

;;;transpose a matrix
;;;code by doug Wilson
(defun transpose (m)
(apply 'mapcar (cons 'list m))
)

;;;Apply a transformation matrix to a vector
(defun mxv (m v)
(mapcar '(lambda (row) (dotprod row v))
m
)
)

;;;Multiply two matrices
(defun mxm (m q)
(setq q (transpose q))
(mapcar '(lambda (row) (mxv q row))
m
)
)


;;;Performs multiple transformations on a point given the Basepoint, Offset,
Scale, and Rotation
;;;This example Rotates the point 5,5,0 90d from the basepoint -1,-1,0
;;;(transformby '(5 5 0) '(-1 -1 0) '(0 0 0) '(1 1 1) (* 0.5 pi))
;;;Returns (-7.0 5.0 0.0)

;;;This example Rotates the point 5,5,0 90d from the basepoint -1,-1,0
;;;AND moves it +10 in the X direction and -6 in the Y direction
;;;(transformby '(5 5 0) '(-1 -1 0) '(10 -6 0) '(1 1 1) (* 0.5 pi))
;;;Returns (3.0 -1.0 0.0)
;;;Bobby C. Jones
(defun TransFormBy (Pnt BasePnt OffsetXYZ scaleXYZ Rot / ScaleX ScaleY
ScaleZ
Tx Ty Tz ScaleM RotateZM MoveM TransM)

(mapcar 'set
'(Scalex ScaleY ScaleZ)
scaleXYZ)
(mapcar 'set
'(Tx Ty Tz)
(mapcar '+ OffsetXYZ BasePnt)
)

(setq scaleM
(list (list ScaleX 0 0 0)
(list 0 ScaleY 0 0)
(list 0 0 ScaleZ 0)
(list 0 0 0 1)
)
RotateZM
(list (list (cos Rot) (- (sin Rot)) 0 0)
(list (sin Rot) (cos rot) 0 0)
(list 0 0 1 0)
(list 0 0 0 1)
)
MoveM
(list (list 1 0 0 Tx)
(list 0 1 0 Ty)
(list 0 0 1 Tz)
(list 0 0 0 1)
)
TransM (mxm MoveM (mxm ScaleM RotateZM))
pnt (mapcar '- pnt BasePnt)
); _end of Setq

(reverse (cdr (reverse (mxv TransM (append pnt '(1))))))
)
--
Bobby C. Jones
http://www.acadx.com
Message 16 of 18
Anonymous
in reply to: Anonymous

I haven't had a chance to try what Luis posted. I will have time today and
I will give your a try. Thanks for everyones input and I hope I understand
it all. I will probably post back here regarding areas I don't understand.

Thanks again.

--
|
-+-------------------------------------------------
| Rob Starz
| Stardsign cad solutions
| iC - AEC Information Center
| www.stardsign.com/aecic.html
| free ADT and Building Systems tools
| *******LayerX available Now*************
| www.stardsign.com/layerx.htm
| Easter Egg Hunt.....win a free version of LayerX
Message 17 of 18
Anonymous
in reply to: Anonymous

I don't know who wrote this, I don't even know if it's relevant for this
thread,
but, hey - I'm posting it anyway !!!
Simple & smart !
Functions described below....

(defun dtr(x) (* x (/ pi 180)))
(defun select(opt / p1 p2 p3 p4 ang code l1)
(setq p1 (getpoint "\nFirst corner: ")
ang (getangle p1 "\nAngle: ")
code 5
)
(prompt "\nOther corner: ")
(while (= code 5)
(setq l1 (grread 1 6 1))
(if (and p2 p4) (grvecs (list 300 p1 p2 p2 p3 p3 p4 p4 p1)))
(setq p3 (cadr l1) code (car l1)
p2 (inters p1 (polar p1 ang 1) p3 (polar p3 (+ ang (dtr 90)) 1) nil)
p4 (inters p1 (polar p1 (+ ang(dtr 90)) 1) p3 (polar p3 (+ ang pi)1)
nil)
)
(grvecs (list 300 p1 p2 p2 p3 p3 p4 p4 p1))
)
(grvecs (list 300 p1 p2 p2 p3 p3 p4 p4 p1))
(eval(ssget opt (list p1 p2 p3 p4)))
)
; FOR ANGULAR WINDOW
(defun aw()(select "wp"))
; FOR ANGULAR CROSSING
(defun ac()(select "cp"))
(prin1)


M@
Message 18 of 18
Anonymous
in reply to: Anonymous

Ok Rob, I was enjoying a nice peaceful lunch looking over some notes and
who's problem pops into my head?? Yes, yours...Not your fault I know, but
I've got my own problems to think about 🙂 What John says here is true, if
your text is at an angle, then the return from (textbox) will be skewed. To
overcome this, simply modify the rotation assoc code, 50, to zero in the
elist that you feed to (textbox). This will give you the textbox corners of
an un-rotated piece of text. Then build your other two points, and pass
them all to my (transformby) function with the desired rotation and you've
got it!!
--
Bobby C. Jones
http://www.acadx.com

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost