DXF code - 3D polylines - autocad

I need a sample DXF code, as clean as possible, to fill with coordinates to draw 3D polylines. I've been able to do this with simple lines, but I'm struggling to do this with 3D polylines. I've tried it a few times, but it did not work. I do not work in the field and I need this to complete a scientific research. The idea is to generate a drawing from GPS coordinates. Can someone help me?

To keep it simple create a minimal DXF R12 file, the advantage of DXF R12 is the minimalistic overall structure and
you don't need handles. Only the ENTITIES SECTION is required:
Important: comments like ""<<< some comment" has to removed in the final file.
0
SECTION
2
ENTITIES
0 <<< 1. POLYLINE entity starts here
POLYLINE
...
0
VERTEX
...
0
VERTEX
...
0
SEQEND
0 <<< 2. POLYLINE entity starts here
POLYLINE
...
0
VERTEX
...
0
VERTEX
...
0
SEQEND
0 <<< end of section marker
ENDSEC
0 <<< end of file marker
EOF
The POLYLINE entity is one of two entities which requires more than one entity, the INSERT entity is the other one.
0 <<< POLYLINE entity
POLYLINE
8 <<< layer group code required
0 <<< layer '0'
62 <<< color group code not required
1 <<< Color number
66 <<< entities follow flag
1 <<< always 1, POLYLINE without vertices is pointless
70 <<< flags, see reference
8 <<< this is a 3D polyline
0 <<< 1. VERTEX entity
VERTEX
8 <<< layer group code required
0 <<< ALWAYS the same as POLYLINE layer!
70 <<< flags
32 <<< 3D polyline vertex
10 <<< x-coord group code
4.0 <<< x-coord value
20 <<< y-coord group code
3.0 <<< y-coord value
30 <<< z-coord group code
2.0 <<< z-coord value
0 <<< 2. VERTEX entity
VERTEX
8
0
70
32
10
8.0
20
5.0
30
0.0
0 <<< 3. VERTEX entity
VERTEX
8
0
70
32
10
2.0
20
4.0
30
9.0
0 <<< required SEQEND entity
SEQEND
DXF reference for POLYLINE: http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-ABF6B778-BE20-4B49-9B58-A94E64CEFFF3
DXF reference for VERTEX: http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-0741E831-599E-4CBF-91E1-8ADBCFD6556D
If you can use Python, look at my ezdxf package: https://ezdxf.mozman.at/
Create a minimal DXF R12 file with the r12writer context manager:
from ezdxf.r12writer import r12writer
with r12writer("YourFile.dxf") as dxf:
dxf.add_polyline([(4, 3, 2), (8, 5, 0), (2, 4, 9)])

Related

how to interpret the rows and columns of H2O confusion matrix

it's said
Vertical : Actual
Across : Predicted
does it mean the rows are actual (i=1 for No,i=2 for Yes)
or the reverse
There is a JIRA ticket here to help with the confusion by printing a clearer message. Currently this message is only available for the multinomial case but will be added for binary classification problems as well.
For example if you run the confusion matrix on the iris dataset which solves a multi-class problem you will get the following output.
Confusion Matrix: Row labels: Actual class; Column labels: Predicted class
Iris-setosa Iris-versicolor Iris-virginica Error Rate
Iris-setosa 42 0 0 0.0000 = 0 / 42
Iris-versicolor 0 37 2 0.0513 = 2 / 39
Iris-virginica 0 1 35 0.0278 = 1 / 36
Totals 42 38 37 0.0256 = 3 / 117
so to answer your question: the row labels are the Actual class, and the column labels are the Predicted class.

Convert diamond matrix 2d coordinates to 1d index and back

I have a 2d game board that expands as tiles are added to the board. Tiles can only be adjacent to existing tiles in the up, down, left and right positions.
So I thought a diamond spiral matrix would be the most efficient way to store the board, but I cannot find a way to convert the x,y coordinates to a 1d array index or the reverse operation.
like this layout
X -3 -2 -1 0 1 2 3
Y 3 13
2 24 5 14
1 23 12 1 6 15
0 22 11 4 0 2 7 16
-1 21 10 3 8 17
-2 20 9 18
-3 19
Tile 1 will always be at position 0, tile 2 will be at 1,2,3 or 4, tile 3 somewhere from 1 to 12 etc.
So I need an algorithm that goes from X,Y to an index and from an index back to the original X and Y.
Anyone know how to do this, or recommend another space filling algorithm that suits my needs. I'm probably going to use Java but would prefer something language neutral.
Thanks
As I can understand form the problem statement, there is no guarantee that the tiles will be filled evenly on the sides. for example:
X -3 -2 -1 0 1 2 3
Y 3 6
2 3 4 5
1 1
0 0 2
-1
So, I think a diamond matrix won't be the best choice.
I would suggest storing them in a hash-map, like implementing a dictionary for 2 letter words.
Also, You need to be more specific to what your requirements are. Like, do you prioritize space complexity over time? Or do you want a fast access time and don't care about memory usage that much.
IMPORTANT :
Also, what is the
Max number of tiles that we have to hold
Max width and height of the board.

Converting points into another coordinate system

There are 3 points in 3D space. There are 2 orthogonal coordinate systems with the same origin. I know coordinates of those 3 points in both coordinate systems. Given a new point with its coordinates in the first coordinate system, how can I find its coordinates in the second coordinate system?
I think it's possible to get a rotation matrix using given points which does this, but I did not succeed doing this.
You can do it using matrix inverses. Three matrix-vector multiplications (e.g. transforming three 3D vectors by a 3x3 matrix) is equivalent to multiplying two 3x3 matrices together.
So, you can put your first set of points in one matrix, call it A:
0 0 1 < vector 1
0 1 0 < vector 2
2 0 0 < vector 3
Then put your second set of points in a second matrix, call it C. As an example, imagine a transform that scales by a factor of 2 around the origin and flips the Y and Z axes:
0 2 0 < vector 1
0 0 2 < vector 2
4 0 0 < vector 3
So, if A x B = C, we need to find the matrix B, which we can find by finding the A-1:
Inverse of A:
0 0 0.5
0 1 0
1 0 0
The multiply A-1 x C (in that order):
2 0 0
0 0 2
0 2 0
This is a transform matrix B that you can apply to new points. Dot-product multiply the vector by the first column to get the transformed X, second column to get the transformed Y, etc.

How to translate based on origin / world space with homogenous matrix

I don't know if this is the right place to ask this or not, since what I'm trying to ask is maybe the basic principle (and its implementation) rather than code specific. I apologize in advance.
Currently, I'm trying to make my own 2D engine using SDL & C++ with my limited knowledge and rusty linear algebra. I'm currently stuck on the transformation part. I've coded my own vectors and matrices class (Vector2, Vector3, Matrix2x2, Matrix3x3). And derived Matrix3x3 into a Transform class to hold the transform of the object in the scene. So, to get the position, it's from these x= elements[0][2], y = elements[1][2], while the angle is from atan(elements[1][0], elements[0][0]).
Now suppose I have this transform for the object:
| 0.86602540378 -0.5 50 |
| 0.5 0.86602540378 -70 |
| 0 0 1 |
Or position = 50,-70 ; rotation = 30 degree.
Now if I have a translation matrix of:
| 1 0 40 |
| 0 1 20 |
| 0 0 1 |
How do I translate the object not based on the relative space of its rotation but based on the world / global space? So that the final transform of the object would be like this:
| 0.86602540378 -0.5 90 |
| 0.5 0.86602540378 -50 |
| 0 0 1 |
Thanks in advance.
In this case, try applying left-multiplication. As you're probably aware, matrix multiplication is not commutative in general. AB is not the same as BA. If you multiply with the translation matrix on the left and the object transform on the right, you'll likely get it.

Can I calculate TP,TN, FPR and FNR in multiclass

If i classify data in 5 class, I get confusion matrix in 5 class classification but I can not calculate it
4822 18 9 0 40
0 1106 0 0 0
0 2 1990 0 0
0 0 1 2000 0
0 0 0 0 12
Can I calculate TP, TN, FPR and FNR in multiclass problem?
Thank you!
You can calculate these values per class and then aggregate them if you wish to do so. In the calculation for one class you treat the class as the "true" and the union of the other classes as "false". To aggregate for an overall value I would suggest to use the median, which is less sensitive to outliers.
Yes, you can calculate these metrics by using the following steps:-
1- Convert your matrix to 2 x 2 matrix as below
a. suppose your first class is A and second class is B for the new 2 x 2 matrix
b. the new 2 x2 matrix should be like this
Predicted Class
A B
A 4822 67 // 67 comes from the summation of 18+9+0+40
B 0 5111 // 0 comes from the summation of 0+0+0+0 under 4822
// 5111 comes from the summation of the remaining numbers
2- Calculate the TP, TN, FP and FN rates using the equations in this URL page: http://www2.cs.uregina.ca/~dbd/cs831/notes/confusion_matrix/confusion_matrix.html

Resources