Go Back   AC3D Forums > Technical > AC3D Developers
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 25th December 2015, 12:35 AM   #1
Thaeris
Junior Member
Member
 
Thaeris's Avatar
 
Join Date: Jun 2009
Posts: 12
Default User-Defined Planar Operations Tools

Hello Friends,

I'm posting this blob of writing here so hopefully I can learn something, and hopefully the rest of us can have a great new tool to use. I've spent a bit too much time re-learning the math to do this, and then preparing this document, so looking into the SDK was not my first perrogative. But, all things in time. No time like right now, right?

INTRODUCTION
*****

This project is intended to be a brief and effective means for adding functionality to the AC3D software package. Previously, shortcomings in controlling the creation and placement of quads in the existing software had forced the use of external tools to precisely generate planar four-sided polygons. This project aims to streamline and implement the operaions of the external software directly into AC3D. In doing so, workflow for precision modeling should increase substantially.

The project aims to first improve precise generation of planar polygons by implementing a "planar intercept" tool, which will create a point within a user-defined plane, thus allowing the creation of planar quads or possibly even larger n-gons by selecting user-defined line segments. An Excel file with a working version of such a calculation has been attached to this post.

The secondary and eventual aims of this project are to establish user-defined planes which allow free movement of points within those planes. This development should ideally be of great benefit to any sort of organic or mechanical modeling, especially when subdivision modeling is used. This should allow for planar quads to form precise edge-looped models, which will then subdivide into similar, even, and planar subdivisions.

ADDITIONAL NOTE: Please know that I'm a bit behind the times with regard to my software - I'm running AC3D 6.4.3 - if this feature is currently in the latest build, then it's time to upgrade!

PROCESS
*****

...Being a forum populated by 3D modelers, I have to expect that the majority here are pretty decent at math. For those who are not, or for the programmers who may be interested in helping, but too lazy to dig up the formulations, this derivation section has been fleshed out here:

Note that three points may define a plane in space. A mathematical model for defining such a plane can be written as follows:

1. So long as only three points are used, they may be compiled in a table as follows:

Coords: X Y Z
(1.) x1 y1 z1
(2.) x2 y2 z2
(3.) x3 y3 z3

2. These points may then be used to calculate a pair of vectors from this point on. For the sake of simplicity, Coordinate #1 will be selected as the common point, with the other two coordinates acting as endpoints for the vectors to be calculated:

Vector #1 = (X1, Y1, Z1): [(x2 - x1), (y2 - y1), (z2 - z1)]
Vector #2 = (X2, Y2, Z2): [(x3 - x1), (y3 - y1), (z3 - z1)]

Logic for this operation is as follows (for those unfamiliar with vector math): A vector constitutes a line segment with magnitude (size) and direction formed between two coordinates. As such, a vector represents a change between the final coordinate and the initial coordinate which form the vector; direction of the vector with respect to each individual axis can thus be seen as differences (hence, x2 - x1, etc.). The magnitude of a vector is the absolute value (positive, net length) of the line segment formed by the vector - the magnitude of the vector will be irrelevant for the remainder of this computation.

3. The resultant vectors may then be multiplied in a "cross product" which will produce a normal vector, or a vector which runs perpendicular to the surface of the plane formed by the three points. Note that the order in which the three original point coordinates were selected (in conjunction with the way the first and second vectors were formed) will result in a normal vector which travels either "forward" or "backward." Despite the direction, either normal vector will be parallel to each other and will also (potentially) be co-linear. It is helpful to create a table of the X, Y, and Z vector coordinates (which are i, j, k, respectively) before calculating the normal vector:

Vec. Cd.: i j k
Vector #1 X1 Y1 Z1
Vector #2 X2 Y2 Z2

Again, i relates to the x-axis system, j to y, and k to z, etc. Note that the new normal vector to be formed will also have x, y, and z coordinates; for the sake of future calculation, i, j, and k coordinates in the normal vector shall be considered as follows: i = NX, j = NY, k = NZ.

Normal = (NX, NY, NZ): [((Y1*Z2)-(Y2*Z1)), ((Z1*X2)-(Z2*X1)), ((X1*Y2)-(X2*Y1))]

...Be advised that most texts do not write the normal/determinant equation this way: NY usually = -1*((X1*Z2)-(X2*Z1)) for the sake of easily visualizing and computing the problem; note that when distributing the -1, the results are the same as shown previously.

4. Given three points, the resultant vectors of these points, and a normal vector, a plane can represented mathematically as follows:

0 = (NX(x-x1))+(NY(y-y1))+(NZ(z-z1))

This means that the sums of any given normal component times the difference between a given coordinate and the initial coordinate will be equal to zero; else, auch a coordinate is non-planar. Therefore, any set of x, y, or z values which are fed into the above equation equalling zero lie within the specified plane.

Now that the equation of a plane has been established, we should find the means of determining where the plane is intersected - to start, we shall make the intersection with a line segment, or the line which continues from a given segment.

5. We can pick two points of our choosing; so long as the line segment formed by the points is not parallel to the defined plane, the line will cross the defined plane at some point. We can begin calculations for the line intersection in a similar manner to what was initiated for defining a plane: we start with a table of coordinates:

Coords: X Y Z
(1.) x'1 y'1 z'1
(2.) x'2 y'2 z'2

Note that we use primes to differentiate the different sets of coordinates for our own purposes (as a note, x'1 is pronounced as "x prime one).

6. From the coordinates selected, a vector can be created:

Line Vector = (LX, LY, LZ): [(x'2-x'1), (y'2-y'1), (z'2-z'1)]

7. Determining where the line will intersect the plane can be difficult with only these assets, however. To make calculations possible, it is necessary to paramatrize the line with parameter t for each coordinate axis which the line travel along:

x = x'1 + (LX*t)
y = y'1 + (LY*t)
z = z'1 + (LZ*t)

8. If these parametric equations are fed back into the planar equation, we can solve for parameter t and plot exactly where a point lies in a given defined plane:

0 = (NX(x'1+(LX*t)-x1))+(NY(y'1+(LY*t)-y1))+(NZ(z'1+(LZ*t)-z1))

...Which becomes:

(NX*LX*t)+(NY*LY*t)+(NZ*LZ*t) = (NX(x1-x'1))+(NY(y1-y'1))+(NZ(z1-z'1))

...Which is solved as:

t = ((NX(x1-x'1))+(NY(y1-y'1))+(NZ(z1-z'1))) / ((NX*LX)+(NY*LY)+(NZ*LZ))

9. To use the solved parameter t, all that is necessary is to feed the value back into the parametric line equations listed in point #7. Again, a working model of this is provided in the attached Excel file.

TEST OUTPUT:
*****

In the previous section, it was shown how the "planar intercept" calculation could be solved. In this section, the Excel file is tested with random coordinate inputs from an equally random model. The meaning of this testing was to ensure that order of coordinate input would have no effect on the outcome of an operation. The results seem to confirm this to be the case!

A. COORDINATE SET (X, Y, Z), COUNTER-CLOCKWISE:

i. -0.230000 -0.123949 -0.455102
ii. -0.500000 -0.255504 -0.443027
iii. -0.500000 -0.045504 -0.343027

B. NORMAL VECTOR OUTPUT (X, Y, Z), CW, CC, RND (i, iii, ii):

i:CW. 0.015691 -0.027000 0.056700
ii:CC. -0.01569 0.027000 -0.056700
iii:RND. 0.015693 -0.026993 0.056700

C. RESULTS OF POINTS A. AND B.:

When using three similar coordinate sets, regardless of order, the normal vector output was the same, positive or negative, despite some minor deviance. Source of error was likely displayed output of individual vertex coordinate.

D. LINE INTERCEPT TO POINT-ON-PLANE:

i. Define first line vertex coordinate (X, Y, Z):
-0.281691 0.097820 0.139716

ii. Define second line vertex coordinate (X, Y, Z):
-0.845238 -0.839527 -1.783759

iii. Verify consistent placement of new point in previous coordinate combinations, with both line orders:

a. First line order vector:
-0.563547 -0.937347 -1.923475

b. Second line order vector:
0.563547 0.937347 1.923475

c. Point placement with first line order:
CW: -0.445574 -0.174766 -0.419642
CC: -0.445574 -0.174766 -0.419642
RND: -0.445574 -0.174766 -0.419642

d. Point placement with second line order:
CW: -0.445574 -0.174766 -0.419642
CC: -0.445574 -0.174766 -0.419642
RND: -0.445574 -0.174766 -0.419642

E. OUTCOME OF TESTING:

Order of inputs does not have to have any significant factor in programming, ideally at least. All vectors are the same, positive or negative - the sign does not manner in a sense, as all of the related vectors lie in the same "line of action." Should the sign of a given vector be a factor by any means, there are logical work-arounds for the problem described in the following section.

PROGRAMMING SUGGESTIONS:
*****

1. If creating a quad from a triangle, ensure that when point is created (and quad is thus formed), original normal vector is used if processing normal is inverted.

FUTURE DEVELOPMENTS:
*****

I'm throwing this out into the breeze at this point, as it's been too long in the tooth up until now. User-defined planar operations will be fun to work with, but I want to learn about expanding AC3D with my linear intercept function first!
Attached Files
File Type: zip Plane-Intercept.zip (6.0 KB, 141 views)
Thaeris is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -4. The time now is 11:07 PM.


AC3D Forum
(C) Inivis Limited 2020