Author Topic: Matrix3d and TransformBy help  (Read 56067 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: Matrix3d and TransformBy help
« Reply #105 on: August 13, 2008, 09:21:09 PM »
I couldn’t find how to get the normal from the face (through the API).

What’s interesting is that Bricscad seems to somehow store the orientation of the solid. I’m NOT sure whats going on yet but it sure is acting different than AutoCAD
« Last Edit: August 13, 2008, 10:05:41 PM by Daniel »

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Matrix3d and TransformBy help
« Reply #106 on: August 13, 2008, 10:15:57 PM »
I've only looked at the lib briefly but using an edge traverser, graba vector from each of the first 2 edges, do a cross product on them and you have the normal of the face.

Basically, the cross product of any 2 vectors gives you a vector perpendicular to the plane created by the 2 vec's. This may vary on the 'winding' of the face edges though, as I'm assuming the traverser follows the winding of the edges it should be giving you a normal pointing away from the face (to the outside of the solid).

Just had a quick peek at the doc's, you're right, no normal!? Even if you get the face's surface.
I noticed that there are point on face etc methods so it must be there somewhere, just not exposed.
I's easy enough to get though using 2 edges of the face you want.
hth
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
Re: Matrix3d and TransformBy help
« Reply #107 on: August 14, 2008, 01:50:12 PM »
Checking the properties of a "box" type solid3d there is a width, height and depth.
However when that box is modified in any way (union, subtract etc.) those values do not appear.

Another thing I noticed is that there is some solid3d dxf information that is proprietary.

3dsolid group codes
 
Group code Description
100            Subclass marker (AcDbModelerGeometry)
70              Modeler format version number (currently = 1)
1                Proprietary data (multiple lines < 255 characters each)
3                Additional lines of proprietary data (if previous group 1 string is greater than 255 characters) (optional)
100            Subclass marker (AcDb3dSolid)
350            Soft-owner ID/handle to history object

I wonder what's in the proprietary data.
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Matrix3d and TransformBy help
« Reply #108 on: August 14, 2008, 04:34:23 PM »
note the history group codes, this is new to the 2007/8/9 modelers, you may be able to get to the root object (it would be the first node in the CSG tree) if it's available?? When you extrude an object you then have the arrow on the extension face that you can grip edit the solid with making it's length longer.

Just a side note, with my C# code, I get a eWasOpenForWrite error on new solids created when I try and modify them with code, turning off SOLIDHIST and using the BREP command fixes the problem which I'll have to fix (probably an upgrade open or similar).
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: Matrix3d and TransformBy help
« Reply #109 on: August 15, 2008, 11:03:01 AM »
I've only looked at the lib briefly but using an edge traverser, graba vector from each of the first 2 edges, do a cross product on them and you have the normal of the face.

Basically, the cross product of any 2 vectors gives you a vector perpendicular to the plane created by the 2 vec's. This may vary on the 'winding' of the face edges though, as I'm assuming the traverser follows the winding of the edges it should be giving you a normal pointing away from the face (to the outside of the solid).

Just had a quick peek at the doc's, you're right, no normal!? Even if you get the face's surface.
I noticed that there are point on face etc methods so it must be there somewhere, just not exposed.
I's easy enough to get though using 2 edges of the face you want.
hth

What is the best face to use, the face with the largest area?

Spike Wilbury

  • Guest
Re: Matrix3d and TransformBy help
« Reply #110 on: August 15, 2008, 11:45:24 AM »
I noticed that there are point on face etc methods

yep... there are some methods avail... but for example the containment ones, do not work...... at least for me...

I tried to move the extreme (2+) points I found aligned to the solid into a face and no luck, I will try to use the mpolygon combination.

With that I can find the face I need and calculate the direction....

A lot to play for this weekend....

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

Spike Wilbury

  • Guest

Spike Wilbury

  • Guest
Re: Matrix3d and TransformBy help
« Reply #113 on: January 21, 2009, 09:38:22 PM »
After more than 120 days.... here is something.-

Base on the work of Gill Barequet

Here.-
http://www.cs.technion.ac.il/~barequet/

I was able to use it inside of my ObjectARX project.

Attached it is the arx, and a drawing (a2007) - for testing.

Note:
This is a beta - debug and not full tested, so expect ERRORS.

How to use the command OBB:
Loaded in the attached drawing, call the command OBB, select a solid and the command will draw four points around the oriented bounding box, if nothing goes wrong :)

Looks, to me that have future, give it a try.


Luis.

SEANT

  • Bull Frog
  • Posts: 345
Re: Matrix3d and TransformBy help
« Reply #114 on: January 22, 2009, 04:54:12 AM »
Definitely looks good on all the slab-sided solids in the drawing.

As a point of interest though; it causes a fatal crash (AutoCAD 2009) if a cylindrical object is selected.
Sean Tessier
AutoCAD 2016 Mechanical

Spike Wilbury

  • Guest
Re: Matrix3d and TransformBy help
« Reply #115 on: January 22, 2009, 10:47:56 AM »
Definitely looks good on all the slab-sided solids in the drawing.

As a point of interest though; it causes a fatal crash (AutoCAD 2009) if a cylindrical object is selected.


Yes, because when it does the traversing on the faces, it returns two points and they are colinear, that's why :)

I will continue playing with this project, and as soon became more stable, will post it in the was C++ forum - the VS SLN.

LE!

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: Matrix3d and TransformBy help
« Reply #116 on: January 23, 2009, 09:30:09 PM »
Nice work Luis..  8-)


Spike Wilbury

  • Guest
Re: Matrix3d and TransformBy help
« Reply #117 on: January 29, 2009, 04:17:01 PM »
Appears that this new algorithm it is working - a total new approach.   :-)

So in case someone wants to run some tests, please do it and let me know if works as expected.

For now, it will just draw two points that are the min and max at the oriented bounding box found and a line between both points.

Again, please remember that this is a debug version and might have or generate some errors.


Load the arx file and call the below command name:
Command: OBB


Note: I have not implemented the function to work with spheres, pyramids, cones.... I'm working on that, at this moment...
Thanks!
« Last Edit: January 29, 2009, 07:39:39 PM by LE »

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: Matrix3d and TransformBy help
« Reply #118 on: January 29, 2009, 07:29:35 PM »
OBB doesn't work for me, sure it's the right command?
thanks
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien

Spike Wilbury

  • Guest
Re: Matrix3d and TransformBy help
« Reply #119 on: January 29, 2009, 07:38:17 PM »
OBB doesn't work for me, sure it's the right command?
thanks

Hi Mick,

Let me upload the file, one more time...