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
--
|
-+-------------------------------------------------
| 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" <r...@stardsignNOSPAM.com> wrote in message
news:660A80C4C50531EF...@in.WebX.maYIadrTaRb...
Thanks
"Rob Starz" <r...@stardsignNOSPAM.com> wrote in message
news:5671797EB6076389...@in.WebX.maYIadrTaRb...
thanks
--
R. Robert Bell, MCSE
http://www.acadx.com
"Rob Starz" <r...@stardsignNOSPAM.com> wrote in message
news:DFD08DEAE0A2AC80...@in.WebX.maYIadrTaRb...
I hope I am explaining what I am looking for properly. I am no Geometry
whiz...so please forgive me.
Good judgement comes from experience.
Experience comes from bad judgement.
"Rob Starz" <r...@stardsignNOSPAM.com> wrote in message
news:DFD08DEAE0A2AC80...@in.WebX.maYIadrTaRb...
Draw a rectangle using the bounding box coordiantes of the rotated copy,
then rotate the box back to the original angle.
Good judgement comes from experience.
Experience comes from bad judgement.
"Rob Starz" <r...@stardsignNOSPAM.com> wrote in message
news:BC075D4C94253261...@in.WebX.maYIadrTaRb...
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)
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" <lu...@slarchitects.com> wrote in message
news:843D3ADDB21A96CD...@in.WebX.maYIadrTaRb...
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:juh...@cadlantic.com
--> http://www.cadlantic.com
2 Village Road
Sea Girt, NJ 08750
Tel. 732-974-1711
FAX 732-528-1332
"Luis Esquivel" <lu...@slarchitects.com> wrote in message
news:843D3ADDB21A96CD...@in.WebX.maYIadrTaRb...
> 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
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
Thanks again.
(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@