MACRO VBA CODES FOR LINE SEGMENTS - SanjoyNath/SanjoyNathGeometrifyingTrigonometry GitHub Wiki

CODES FOR LINE SEGMENTS HANDLING


'''Sub TOSAVEPICS() '''' '''' TOSAVEPICS Macro '''' ''' '''' ''' ActiveSheet.ChartObjects("Chart 2").Activate ''' ActiveChart.PlotArea.Select ''' ActiveSheet.ChartObjects("Chart 2").Activate ''' ActiveChart.ChartArea.Select ''' ActiveSheet.ChartObjects("Chart 2").Activate ''' Range("E37").Select ''' ActiveSheet.ChartObjects("Chart 2").Activate ''' ActiveSheet.ChartObjects("Chart 2").Activate ''' ActiveChart.ChartArea.Copy ''' Range("E40").Select ''' ActiveSheet.ChartObjects("Chart 2").Activate '''End Sub

'''''''Sub ExportChart() ''''''' Dim sChartName As String ''''''' Dim sPrompt As String ''''''' Dim sDefault As String ''''''' ''''''' If ActiveSheet Is Nothing Then GoTo ExitSub ''''''' If ActiveChart Is Nothing Then GoTo ExitSub ''''''' ''''''' sPrompt = "Chart will be exported into directory of active workbook." ''''''' sPrompt = sPrompt & vbNewLine & vbNewLine ''''''' sPrompt = sPrompt & "Enter a file name for the chart, " ''''''' sPrompt = sPrompt & "including an image file extension (e.g., .png, .gif)." ''''''' sDefault = "" ''''''' ''''''' Do ''''''' sChartName = Application.InputBox(sPrompt, "Export Chart", sDefault, , , , , 2) ''''''' ''''''' If Len(sChartName) = 0 Then GoTo ExitSub ''''''' If sChartName = "False" Then GoTo ExitSub ''''''' ''''''' Select Case True ''''''' Case UCase$(Right(sChartName, 4)) = ".PNG" ''''''' Case UCase$(Right(sChartName, 4)) = ".GIF" ''''''' Case UCase$(Right(sChartName, 4)) = ".JPG" ''''''' Case UCase$(Right(sChartName, 4)) = ".JPE" ''''''' Case UCase$(Right(sChartName, 5)) = ".JPEG" ''''''' Case Else ''''''' sChartName = sChartName & ".png" ''''''' End Select ''''''' ''''''' If Not FileExists(ActiveWorkbook.Path & "" & sChartName) Then Exit Do ''''''' ''''''' sPrompt = "A file named '" & sChartName & "' already exists." ''''''' sPrompt = sPrompt & vbNewLine & vbNewLine ''''''' sPrompt = sPrompt & "Select a unique file name, " ''''''' sPrompt = sPrompt & "including an image file extension (e.g., .png, .gif)." ''''''' sDefault = sChartName ''''''' ''''''' Loop ''''''' ''''''' ActiveChart.Export ActiveWorkbook.Path & "" & sChartName '''''''ExitSub: ''''''' '''''''End Sub

Public SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_ROTATIONS_MATRIX As Matrix Public SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_TRANSLATIONS_MATRIX As Matrix Public SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_SCALING_MATRIX As Matrix Public SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_REFLECTIONS_MATRIX As Matrix

Public Type SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_POINT_TYPE

X As Double Y As Double Z As Double

End Type 'Public Type SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_POINT_TYPE

Public Type SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT

X1 As Double Y1 As Double Z1 As Double

X2 As Double Y2 As Double Z2 As Double

LINE_SEGMENT_LENGTH As Double LINE_SEGMENT_SLOPE_GRADIENT As Double LINE_SEGMENT_CONSTANT_C As Double

ANGLE_WITH_X_AXIS_IN_DEGREES As Double ANGLE_WITH_X_AXIS_IN_RADIANS As Double

PERPENDICULAR_DISTANCE_FROM_ORIGIN As Double NEAREST_POINT_FROM_ORIGIN As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_POINT_TYPE

LINE_SEGMENT_NAME As String LINE_SEGMENT_INITIAL As String

'THIS CAUSES CIRCULAR REFERENCES ERRORS 'NEAREST_PERPENDICULAR_VECTOR_FROM_ORIGIN As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_VECTOR_TYPE

INTERCEPT_LENGTH_ON_X_AXIS As Double INTERCEPT_LENGTH_ON_Y_AXIS As Double

End Type 'Public Type SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_LINE_SEGMENT

Public Function SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_3_X_3_MULTIPLY_MATRIX(MAT_1() As Double, MAT_2() As Double) As Double() 'WE HAVE REPLACED THIS SINCE TESTS FAILS MultiplyMatrix

'F MEANS FIRST S MEANS SECOND

Dim FDATA_1_1, FDATA_1_2, FDATA_1_3, FDATA_2_1, FDATA_2_2, FDATA_2_3, FDATA_3_1, FDATA_3_2, FDATA_3_3 As Double Dim SDATA_1_1, SDATA_1_2, SDATA_1_3, SDATA_2_1, SDATA_2_2, SDATA_2_3, SDATA_3_1, SDATA_3_2, SDATA_3_3 As Double

Dim TEMP_MATRIX_TO_RETURN_DOUBLE_ARRAY(1 To 3, 1 To 3) As Double

'''''''FDATA_1_1 = MAT_1.Element(1, 1) '''''''FDATA_1_2 = MAT_1.Element(1, 2) '''''''FDATA_1_3 = MAT_1.Element(1, 3) ''''''' ''''''' '''''''FDATA_1_1 = MAT_1.Element(2, 1) '''''''FDATA_1_2 = MAT_1.Element(2, 2) '''''''FDATA_1_3 = MAT_1.Element(2, 3) ''''''' ''''''' '''''''FDATA_3_1 = MAT_1.Element(3, 1) '''''''FDATA_3_2 = MAT_1.Element(3, 2) '''''''FDATA_3_3 = MAT_1.Element(3, 3) ''''''' ''''''' ''''''' '''''''SDATA_1_1 = MAT_2.Element(1, 1) '''''''SDATA_1_2 = MAT_2.Element(1, 2) '''''''SDATA_1_3 = MAT_2.Element(1, 3) ''''''' ''''''' '''''''SDATA_1_1 = MAT_2.Element(2, 1) '''''''SDATA_1_2 = MAT_2.Element(2, 2) '''''''SDATA_1_3 = MAT_2.Element(2, 3) ''''''' ''''''' '''''''SDATA_3_1 = MAT_2.Element(3, 1) '''''''SDATA_3_2 = MAT_2.Element(3, 2) '''''''SDATA_3_3 = MAT_2.Element(3, 3)

'WE HAVE TO DO ALL THINGS HERE WHICH WE HAVE NOT DONE YET

SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_3_X_3_MULTIPLY_MATRIX = TEMP_MATRIX_TO_RETURN

End Function 'Public Function SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_3_X_3_MULTIPLY_MATRIX(MAT_1 As Matrix, MAT_2 As Matrix) As Double()

Public Function CREATE_2D_LINE_SEGMENT_OBJECT_FROM_GIVEN_POINTS(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double) As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT

Dim TEMP_RETURNING_2D_LINE_SEGMENT As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT

TEMP_RETURNING_2D_LINE_SEGMENT.X1 = X1 TEMP_RETURNING_2D_LINE_SEGMENT.Y1 = Y1 TEMP_RETURNING_2D_LINE_SEGMENT.Z1 = 0

TEMP_RETURNING_2D_LINE_SEGMENT.X2 = X2 TEMP_RETURNING_2D_LINE_SEGMENT.Y2 = Y2 TEMP_RETURNING_2D_LINE_SEGMENT.Z2 = 0

        If (X1 = X2) Then
          X2 = X1 + 0.0000001
          
        End If

TEMP_RETURNING_2D_LINE_SEGMENT.LINE_SEGMENT_NAME = "TESTING" TEMP_RETURNING_2D_LINE_SEGMENT.LINE_SEGMENT_INITIAL = "T"

TEMP_RETURNING_2D_LINE_SEGMENT.LINE_SEGMENT_SLOPE_GRADIENT = (Y2 - Y1) / (X2 - X1)

TEMP_RETURNING_2D_LINE_SEGMENT.LINE_SEGMENT_CONSTANT_C = Y1 - ((TEMP_RETURNING_2D_LINE_SEGMENT.LINE_SEGMENT_SLOPE_GRADIENT) * X1)

TEMP_RETURNING_2D_LINE_SEGMENT.INTERCEPT_LENGTH_ON_X_AXIS = ((-1) * TEMP_RETURNING_2D_LINE_SEGMENT.LINE_SEGMENT_CONSTANT_C) / (TEMP_RETURNING_2D_LINE_SEGMENT.LINE_SEGMENT_SLOPE_GRADIENT) TEMP_RETURNING_2D_LINE_SEGMENT.INTERCEPT_LENGTH_ON_Y_AXIS = TEMP_RETURNING_2D_LINE_SEGMENT.LINE_SEGMENT_CONSTANT_C

CREATE_2D_LINE_SEGMENT_OBJECT_FROM_GIVEN_POINTS = TEMP_RETURNING_2D_LINE_SEGMENT

End Function 'Public Function CREATE_2D_LINE_SEGMENT_OBJECT_FROM_GIVEN_POINTS(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double) As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT

Public Function RETURN_SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_PIVOTTED_ROTATIONS_MATRIX_DISCARDED(PIVOT_POINT_X As Double, PIVOT_POINT_Y As Double, PIVOT_POINT_Z As Double, ROTATIONS_ANGLE_IN_DEGREES As Double) As Matrix

Dim ROTATIONS_ANGLE_IN_RADIANS As Double Dim PI As Double PI = Math.Atn(1) * 4

ROTATIONS_ANGLE_IN_RADIANS = (PI / 180) * ROTATIONS_ANGLE_IN_DEGREES

Dim COS_THETA As Double Dim SIN_THETA As Double

COS_THETA = Cos(ROTATIONS_ANGLE_IN_RADIANS) SIN_THETA = Sin(ROTATIONS_ANGLE_IN_RADIANS)

Dim TEMP_COMPLETE_MATRIX_FOR_PIVOTTED_ROTATION As Matrix

Dim TEMP_PRE_TRANSLATIONS_MATRIX As Matrix Dim TEMP_MID_ROTATIONS_MATRIX As Matrix Dim TEMP_POST_TRANSLATIONS_MATRIX As Matrix

TEMP_PRE_TRANSLATIONS_MATRIX = CREATE_DEFAULT_3_X_3_MATRIX() TEMP_MID_ROTATIONS_MATRIX = CREATE_DEFAULT_3_X_3_MATRIX() TEMP_POST_TRANSLATIONS_MATRIX = CREATE_DEFAULT_3_X_3_MATRIX()

TEMP_COMPLETE_MATRIX_FOR_PIVOTTED_ROTATION = CREATE_DEFAULT_3_X_3_MATRIX()

'''TEMP_PRE_TRANSLATIONS_MATRIX.m = 3 '''TEMP_PRE_TRANSLATIONS_MATRIX.n = 3 ''' '''TEMP_MID_ROTATIONS_MATRIX.m = 3 '''TEMP_MID_ROTATIONS_MATRIX.n = 3 ''' '''TEMP_POST_TRANSLATIONS_MATRIX.m = 3 '''TEMP_POST_TRANSLATIONS_MATRIX.n = 3 ''' '''TEMP_COMPLETE_MATRIX_FOR_PIVOTTED_ROTATION.m = 3 '''TEMP_COMPLETE_MATRIX_FOR_PIVOTTED_ROTATION.n = 3

'Use WITH to cache UDT/Object references and boost speed! With TEMP_MID_ROTATIONS_MATRIX ReDim .Element(m, n) ' Allocate memory to store matrix .m = m ' Set the dimentions .n = n

' Fill the matrix with data, if any ' If UBound(Values) > 0 Then ' For i = 1 To m ' For j = 1 To n ' ' Out of data? Skip out of loop ' ' If k > UBound(Values) Then Exit For ' ' 'we have to implement this in our own settings .Element(i, j) = Values(k) ' Store data in matrix ' ' ' k = k + 1 ' Next data element ' Next j ' ' Out of data? Skip out of loop ' ' If k > UBound(Values) Then Exit For ' Next i

.Element(1, 1) = COS_THETA .Element(1, 2) = SIN_THETA .Element(1, 3) = 0

.Element(2, 1) = (-1) * SIN_THETA .Element(2, 2) = COS_THETA .Element(2, 3) = 0

.Element(3, 1) = 0 .Element(3, 2) = 0 .Element(3, 3) = 1

'End If End With 'With TEMP_MID_ROTATIONS_MATRIX

'Use WITH to cache UDT/Object references and boost speed! With TEMP_PRE_TRANSLATIONS_MATRIX ReDim .Element(m, n) ' Allocate memory to store matrix .m = m ' Set the dimentions .n = n

' Fill the matrix with data, if any ' If UBound(Values) > 0 Then ' For i = 1 To m ' For j = 1 To n ' ' Out of data? Skip out of loop ' ' If k > UBound(Values) Then Exit For ' ' 'we have to implement this in our own settings .Element(i, j) = Values(k) ' Store data in matrix ' ' ' k = k + 1 ' Next data element ' Next j ' ' Out of data? Skip out of loop ' ' If k > UBound(Values) Then Exit For ' Next i

.Element(1, 1) = 1 .Element(1, 2) = 0 .Element(1, 3) = 0

.Element(2, 1) = 0 .Element(2, 2) = 1 .Element(2, 3) = 0

.Element(3, 1) = (-1) * PIVOT_POINT_X .Element(3, 2) = (-1) * PIVOT_POINT_Y .Element(3, 3) = 1

'End If End With 'With TEMP_PRE_TRANSLATIONS_MATRIX

'Use WITH to cache UDT/Object references and boost speed! With TEMP_POST_TRANSLATIONS_MATRIX ReDim .Element(m, n) ' Allocate memory to store matrix .m = m ' Set the dimentions .n = n

' Fill the matrix with data, if any ' If UBound(Values) > 0 Then ' For i = 1 To m ' For j = 1 To n ' ' Out of data? Skip out of loop ' ' If k > UBound(Values) Then Exit For ' ' 'we have to implement this in our own settings .Element(i, j) = Values(k) ' Store data in matrix ' ' ' k = k + 1 ' Next data element ' Next j ' ' Out of data? Skip out of loop ' ' If k > UBound(Values) Then Exit For ' Next i

.Element(1, 1) = 1 .Element(1, 2) = 0 .Element(1, 3) = 0

.Element(2, 1) = 0 .Element(2, 2) = 1 .Element(2, 3) = 0

.Element(3, 1) = PIVOT_POINT_X .Element(3, 2) = PIVOT_POINT_Y .Element(3, 3) = 1

'End If End With 'With TEMP_POST_TRANSLATIONS_MATRIX

'THESE ARE NOT WORKING SO WE ARE CHANGING THESE LOGICS WE WILL DO JUGAD TO AVOID THE MATRIX DATA TYPE BUT WILL RETURN THE MATRIX DATA TEMP_COMPLETE_MATRIX_FOR_PIVOTTED_ROTATION = Multiply_Matrix(TEMP_PRE_TRANSLATIONS_MATRIX, TEMP_MID_ROTATIONS_MATRIX) TEMP_COMPLETE_MATRIX_FOR_PIVOTTED_ROTATION = Multiply_Matrix(TEMP_COMPLETE_MATRIX_FOR_PIVOTTED_ROTATION, TEMP_POST_TRANSLATIONS_MATRIX)

RETURN_SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_PIVOTTED_ROTATIONS_MATRIX_DISCARDED = TEMP_COMPLETE_MATRIX_FOR_PIVOTTED_ROTATION

End Function 'Public Function RETURN_SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_PIVOTTED_ROTATIONS_MATRIX_DISCARDED(PIVOT_POINT_X As Double, PIVOT_POINT_Y As Double, PIVOT_POINT_Z As Double, ROTATIONS_ANGLE_IN_DEGREES As Double) As Matrix

Public Function SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_MatrixProduct(A() As Double, B() As Double) As Double() On Error Resume Next 'Assumes that A,B are 1-based variant arrays

Dim m As Long, n As Long, p As Long, i As Long, j As Long, k As Long
Dim C() As Double

' If TypeName(A) = "Range" Then A = A.Value ' If TypeName(B) = "Range" Then B = B.Value

m = UBound(A, 1)
p = UBound(A, 2)
If UBound(B, 1) <> p Then
    MatrixProduct = "Not Defined!"
    Exit Function
End If
n = UBound(B, 2)
If (n = 0) Then n = 1


ReDim C(1 To m, 1 To n)
For i = 1 To m
    For j = 1 To n
        For k = 1 To p
            C(i, j) = C(i, j) + A(i, k) * B(k, j)
        Next k
    Next j
Next i
SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_MatrixProduct = C

End Function 'Public Function SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_MatrixProduct(A As Variant, B As Variant) As Variant

''''''''THIS IS FRESH HANDLING OF THE SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY DOUBLE ARRAY '''''''Public Function SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_MULTIPLY_PURE_DOUBLE_3_X_3_ARRAY_MATRIX(MAT_1() As Double, MAT_2() As Double) As Double() ''''''' '''''''Dim TEMP_RETURN_PRODUCT_ARRAY() As Double '''''''ReDim TEMP_RETURN_PRODUCT_ARRAY(1 To 3, 1 To 3) ''''''' '''''''TEMP_RETURN_PRODUCT_ARRAY(1, 1) = MAT_1(1, 1) * MAT_2(1, 1) + MAT_1(1, 2) * MAT_2(2, 1) + MAT_1(1, 3) * MAT_2(3, 1) '''''''TEMP_RETURN_PRODUCT_ARRAY(1, 2) = MAT_1(1, 1) * MAT_2(1, 1) + MAT_1(1, 2) * MAT_2(2, 1) + MAT_1(1, 3) * MAT_2(3, 1) ''''''' '''''''SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_MULTIPLY_PURE_DOUBLE_3_X_3_ARRAY_MATRIX = TEMP_RETURN_PRODUCT_ARRAY '''''''End Function 'Public Function SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_MULTIPLY_PURE_DOUBLE_3_X_3_ARRAY_MATRIX(MAT_1() As Double, MAT_2() As Double) As Double()

'WE HAVE REFINED THIS CODE NOW FOR THE FUNCTIONAL PROGRAMMING OF THE ROTATIONS AND FOR THE PIVOTING Public Function RETURN_SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_PIVOTTED_ROTATIONS_MATRIX_DOUBLE_3_X_3_ARRAY(PIVOT_POINT_X As Double, PIVOT_POINT_Y As Double, PIVOT_POINT_Z As Double, ROTATIONS_ANGLE_IN_DEGREES As Double) As Double()

Dim ROTATIONS_ANGLE_IN_RADIANS As Double Dim PI As Double PI = Math.Atn(1) * 4

ROTATIONS_ANGLE_IN_RADIANS = (PI / 180) * ROTATIONS_ANGLE_IN_DEGREES

Dim COS_THETA As Double Dim SIN_THETA As Double

COS_THETA = Cos(ROTATIONS_ANGLE_IN_RADIANS) SIN_THETA = Sin(ROTATIONS_ANGLE_IN_RADIANS)

Dim temp_calculations_array_double() As Double

Dim TEMP_3_X_3_DOUBLE_ARRAY_FOR_PIVOTING() As Double

Dim TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_ORIGIN(1 To 3, 1 To 3) As Double Dim TEMP_3_X_3_DOUBLE_ARRAY_FOR_ROTATE_AT_ORIGIN(1 To 3, 1 To 3) As Double Dim TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_PIVOT(1 To 3, 1 To 3) As Double

TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_ORIGIN(1, 1) = 1 TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_ORIGIN(1, 2) = 0 TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_ORIGIN(1, 3) = 0

TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_ORIGIN(2, 1) = 0 TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_ORIGIN(2, 2) = 1 TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_ORIGIN(2, 3) = 0

TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_ORIGIN(3, 1) = (-1) * PIVOT_POINT_X TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_ORIGIN(3, 2) = (-1) * PIVOT_POINT_Y TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_ORIGIN(3, 3) = 1

TEMP_3_X_3_DOUBLE_ARRAY_FOR_ROTATE_AT_ORIGIN(1, 1) = COS_THETA TEMP_3_X_3_DOUBLE_ARRAY_FOR_ROTATE_AT_ORIGIN(1, 2) = SIN_THETA TEMP_3_X_3_DOUBLE_ARRAY_FOR_ROTATE_AT_ORIGIN(1, 3) = 0

TEMP_3_X_3_DOUBLE_ARRAY_FOR_ROTATE_AT_ORIGIN(2, 1) = (-1) * SIN_THETA TEMP_3_X_3_DOUBLE_ARRAY_FOR_ROTATE_AT_ORIGIN(2, 2) = COS_THETA TEMP_3_X_3_DOUBLE_ARRAY_FOR_ROTATE_AT_ORIGIN(2, 3) = 0

TEMP_3_X_3_DOUBLE_ARRAY_FOR_ROTATE_AT_ORIGIN(3, 1) = 0 TEMP_3_X_3_DOUBLE_ARRAY_FOR_ROTATE_AT_ORIGIN(3, 2) = 0 TEMP_3_X_3_DOUBLE_ARRAY_FOR_ROTATE_AT_ORIGIN(3, 3) = 1

TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_PIVOT(1, 1) = 1 TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_PIVOT(1, 2) = 0 TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_PIVOT(1, 3) = 0

TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_PIVOT(2, 1) = 0 TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_PIVOT(2, 2) = 1 TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_PIVOT(2, 3) = 0

TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_PIVOT(3, 1) = (1) * PIVOT_POINT_X TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_PIVOT(3, 2) = (1) * PIVOT_POINT_Y TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_PIVOT(3, 3) = 1

'we are not getting correct data for this order so we are reversing this temp_calculations_array_double = SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_MatrixProduct(TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_ORIGIN, TEMP_3_X_3_DOUBLE_ARRAY_FOR_ROTATE_AT_ORIGIN) TEMP_3_X_3_DOUBLE_ARRAY_FOR_PIVOTING = SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_MatrixProduct(temp_calculations_array_double, TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_PIVOT)

'temp_calculations_array_double = SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_MatrixProduct(TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_ORIGIN, TEMP_3_X_3_DOUBLE_ARRAY_FOR_ROTATE_AT_ORIGIN) 'TEMP_3_X_3_DOUBLE_ARRAY_FOR_PIVOTING = SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_MatrixProduct(temp_calculations_array_double, TEMP_3_X_3_DOUBLE_ARRAY_FOR_TRANSLATE_TO_PIVOT)

RETURN_SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_PIVOTTED_ROTATIONS_MATRIX_DOUBLE_3_X_3_ARRAY = TEMP_3_X_3_DOUBLE_ARRAY_FOR_PIVOTING

End Function 'Public Function RETURN_SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_PIVOTTED_ROTATIONS_MATRIX_DOUBLE_3_X_3_ARRAY(PIVOT_POINT_X As Double, PIVOT_POINT_Y As Double, PIVOT_POINT_Z As Double, ROTATIONS_ANGLE_IN_DEGREES As Double) As Matrix Public Function RETURN_SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_PIVOTTED_ROTATED_POINT_SET(FROM_POINT_SET() As Double, PIVOT_POINT_FOR_ROTATIONS As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_POINT_TYPE, ROTATIONS_ANGLE_IN_DEGREES As Double) As Double()

Dim TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET() As Double

'1 To UBound(FROM_POINT_SET, 1), 1 To UBound(FROM_POINT_SET, 2) ReDim TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET(1 To 1, 1 To 1) 'THIS FLUSHES PREVIOUS DATA

ReDim TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET(1 To UBound(FROM_POINT_SET, 1), 1 To UBound(FROM_POINT_SET, 2))

Dim TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX As Matrix Dim TEMP_ROTATED_COORDINATES_MATRIX As Matrix

Dim TEMP_COMPLETE_ROTATIONS_TRANSFORMATIONS_MATRIX As Matrix Dim TEMP_COMPLETE_ROTATIONS_TRANSFORMATIONS_MATRIX_DOUBLE_ARRAY() As Double

Dim TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY() As Double

ReDim TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(1 To 3)

'WE HAVE STOPPED THIS TEMP_COMPLETE_ROTATIONS_TRANSFORMATIONS_MATRIX = RETURN_SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_PIVOTTED_ROTATIONS_MATRIX(PIVOT_POINT_FOR_ROTATIONS.X, PIVOT_POINT_FOR_ROTATIONS.Y, PIVOT_POINT_FOR_ROTATIONS.Z, ROTATIONS_ANGLE_IN_DEGREES)

Dim PREPARED_TRANSFORMATIONS_ROTATIONS_AT_PIVOT_CONVERSIONS_ARRAY_DOUBLE() As Double

PREPARED_TRANSFORMATIONS_ROTATIONS_AT_PIVOT_CONVERSIONS_ARRAY_DOUBLE = RETURN_SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_PIVOTTED_ROTATIONS_MATRIX_DOUBLE_3_X_3_ARRAY(PIVOT_POINT_FOR_ROTATIONS.X, PIVOT_POINT_FOR_ROTATIONS.Y, PIVOT_POINT_FOR_ROTATIONS.Z, ROTATIONS_ANGLE_IN_DEGREES)

        For RRR = 1 To UBound(FROM_POINT_SET, 1) Step 1
        
                    TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(1) = FROM_POINT_SET(RRR, 1)
                    TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(2) = FROM_POINT_SET(RRR, 2)
                    TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(3) = FROM_POINT_SET(RRR, 3)
                     
       'there is chance of error here TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY = SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_MatrixProduct(PREPARED_TRANSFORMATIONS_ROTATIONS_AT_PIVOT_CONVERSIONS_ARRAY_DOUBLE, TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY)

' there are chances of error in this way of working TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET(RRR, 1) = TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(1) ' there are chances of error in this way of working TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET(RRR, 2) = TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(2) ' there are chances of error in this way of working TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET(RRR, 3) = TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(3)

TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET(RRR, 1) = PREPARED_TRANSFORMATIONS_ROTATIONS_AT_PIVOT_CONVERSIONS_ARRAY_DOUBLE(1, 1) * TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(1) + PREPARED_TRANSFORMATIONS_ROTATIONS_AT_PIVOT_CONVERSIONS_ARRAY_DOUBLE(1, 2) * TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(2) + PREPARED_TRANSFORMATIONS_ROTATIONS_AT_PIVOT_CONVERSIONS_ARRAY_DOUBLE(1, 3) * TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(3) TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET(RRR, 2) = PREPARED_TRANSFORMATIONS_ROTATIONS_AT_PIVOT_CONVERSIONS_ARRAY_DOUBLE(2, 1) * TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(1) + PREPARED_TRANSFORMATIONS_ROTATIONS_AT_PIVOT_CONVERSIONS_ARRAY_DOUBLE(2, 2) * TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(2) + PREPARED_TRANSFORMATIONS_ROTATIONS_AT_PIVOT_CONVERSIONS_ARRAY_DOUBLE(2, 3) * TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(3) TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET(RRR, 3) = PREPARED_TRANSFORMATIONS_ROTATIONS_AT_PIVOT_CONVERSIONS_ARRAY_DOUBLE(3, 1) * TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(1) + PREPARED_TRANSFORMATIONS_ROTATIONS_AT_PIVOT_CONVERSIONS_ARRAY_DOUBLE(3, 2) * TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(2) + PREPARED_TRANSFORMATIONS_ROTATIONS_AT_PIVOT_CONVERSIONS_ARRAY_DOUBLE(3, 3) * TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(3)

' TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET(RRR, 2) = TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(2) ' TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET(RRR, 3) = TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX_1_X_3_DOUBLE_ARRAY(3)

                   ' For CCC = 1 To UBound(FROM_POINT_SET, 2) Step 1

''''''' TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX.m = 1 ''''''' TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX.n = 3 ''''''' ''''''' TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX.Element(1, 1) = FROM_POINT_SET(RRR, 1) ''''''' TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX.Element(1, 2) = FROM_POINT_SET(RRR, 2) ''''''' TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX.Element(1, 3) = FROM_POINT_SET(RRR, 3) ''''''' ''''''' 'THE ACTUAL TRANSFORMATIONS ARE DONE HERE FOR ROTATIONS ''''''' 'WE HAVE STOPPED THIS TEMP_ROTATED_COORDINATES_MATRIX = MultiplyMatrix(TEMP_COMPLETE_ROTATIONS_TRANSFORMATIONS_MATRIX, TEMP_CURRENT_POINT_SETS_COORDINATES_MATRIX) ''''''' TEMP_COMPLETE_ROTATIONS_TRANSFORMATIONS_MATRIX_DOUBLE_ARRAY ''''''' ''''''' TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET(RRR, 1) = TEMP_ROTATED_COORDINATES_MATRIX.Element(1, 0) ''''''' TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET(RRR, 2) = TEMP_ROTATED_COORDINATES_MATRIX.Element(1, 2) ''''''' TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET(RRR, 3) = TEMP_ROTATED_COORDINATES_MATRIX.Element(1, 3)

                   ' Next CCC
        
        Next RRR 'For RRR = 1 To UBound(FROM_POINT_SET, 1) Step 1
        
        
        
       RETURN_SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_PIVOTTED_ROTATED_POINT_SET = TEMP_RETURNING_ARRAY_FOR_TRANSFORMED_POINT_SET

End Function 'Public Function RETURN_SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_PIVOTTED_ROTATED_POINT_SET(FROM_POINT_SET() As Double, PIVOT_POINT_FOR_ROTATIONS As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_POINT_TYPE, ROTATIONS_ANGLE_IN_DEGREES As Double) As Double()

Public Function GET_ROTATED_LINE_SEGMENT_FROM_GIVEN_LINE_SEGMENT_WITH_START_POINT_AND_ANGLE(GIVEN_LINE_SEGMENT As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT, GIVEN_ANGLE_DEGREES As Double) As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT

        Dim TEMP_POINT_SET(1 To 2, 1 To 3) As Double
        
        Dim RETURNED_POINT_SET() As Double
        
        TEMP_POINT_SET(1, 1) = GIVEN_LINE_SEGMENT.X1
        TEMP_POINT_SET(1, 2) = GIVEN_LINE_SEGMENT.Y1
        TEMP_POINT_SET(1, 3) = GIVEN_LINE_SEGMENT.Z1
        
        
        TEMP_POINT_SET(2, 1) = GIVEN_LINE_SEGMENT.X2
        TEMP_POINT_SET(2, 2) = GIVEN_LINE_SEGMENT.Y2
        TEMP_POINT_SET(2, 3) = GIVEN_LINE_SEGMENT.Z2
        
        Dim PIVOT_AS_START_POINT As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_POINT_TYPE
        
        PIVOT_AS_START_POINT.X = GIVEN_LINE_SEGMENT.X1
        PIVOT_AS_START_POINT.Y = GIVEN_LINE_SEGMENT.Y1
        PIVOT_AS_START_POINT.Z = GIVEN_LINE_SEGMENT.Z1
        
        
        RETURNED_POINT_SET = RETURN_SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_PIVOTTED_ROTATED_POINT_SET(TEMP_POINT_SET, PIVOT_AS_START_POINT, GIVEN_ANGLE_DEGREES)
        
        Dim RETURNED_LINE_SEGMENT As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT
        
        RETURNED_LINE_SEGMENT = CREATE_2D_LINE_SEGMENT_OBJECT_FROM_GIVEN_POINTS(RETURNED_POINT_SET(1, 1), RETURNED_POINT_SET(1, 2), RETURNED_POINT_SET(2, 1), RETURNED_POINT_SET(2, 2))
        
        
        GET_ROTATED_LINE_SEGMENT_FROM_GIVEN_LINE_SEGMENT_WITH_START_POINT_AND_ANGLE = RETURNED_LINE_SEGMENT

End Function 'Public Function GET_ROTATED_LINE_SEGMENT_FROM_GIVEN_LINE_SEGMENT_WITH_START_POINT_AND_ANGLE(GIVEN_LINE_SEGMENT As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT, GIVEN_ANGLE_DEGREES As Double) As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT

Public Function GET_ROTATED_2D_LINE_SEGMENT_FROM_X1Y1X2Y2_DATA_START_POINT_AS_PIVOT(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, GIVEN_ANGLE_IN_DEGREES As Double) As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT

        Dim TEMP_LINE_SEGMENT As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT
        
        TEMP_LINE_SEGMENT = CREATE_2D_LINE_SEGMENT_OBJECT_FROM_GIVEN_POINTS(X1, Y1, X2, Y2)
        GET_ROTATED_2D_LINE_SEGMENT_FROM_X1Y1X2Y2_DATA_START_POINT_AS_PIVOT = GET_ROTATED_LINE_SEGMENT_FROM_GIVEN_LINE_SEGMENT_WITH_START_POINT_AND_ANGLE(TEMP_LINE_SEGMENT, GIVEN_ANGLE_IN_DEGREES)

End Function 'Public Function GET_ROTATED_2D_LINE_SEGMENT_FROM_X1Y1X2Y2_DATA_START_POINT_AS_PIVOT(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, GIVEN_ANGLE_IN_DEGREES As Double) As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT

Public Function GET_TEST_ROTATED_X1_FOR_X1Y1X2Y2_THETA(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, GIVEN_ANGLE_IN_DEGREES As Double) As Double Dim TEMP_LINE_SEGMENT As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT

TEMP_LINE_SEGMENT = GET_ROTATED_2D_LINE_SEGMENT_FROM_X1Y1X2Y2_DATA_START_POINT_AS_PIVOT(X1, Y1, X2, Y2, GIVEN_ANGLE_IN_DEGREES) GET_TEST_ROTATED_X1_FOR_X1Y1X2Y2_THETA = TEMP_LINE_SEGMENT.X1 End Function 'Public Function GET_TEST_ROTATED_X1_FOR_X1Y1X2Y2_THETA(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, GIVEN_ANGLE_IN_DEGREES As Double) As Double

Public Function GET_TEST_ROTATED_Y1_FOR_X1Y1X2Y2_THETA(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, GIVEN_ANGLE_IN_DEGREES As Double) As Double Dim TEMP_LINE_SEGMENT As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT

TEMP_LINE_SEGMENT = GET_ROTATED_2D_LINE_SEGMENT_FROM_X1Y1X2Y2_DATA_START_POINT_AS_PIVOT(X1, Y1, X2, Y2, GIVEN_ANGLE_IN_DEGREES) GET_TEST_ROTATED_Y1_FOR_X1Y1X2Y2_THETA = TEMP_LINE_SEGMENT.Y1 End Function 'Public Function GET_TEST_ROTATED_Y1_FOR_X1Y1X2Y2_THETA(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, GIVEN_ANGLE_IN_DEGREES As Double) As Double

Public Function GET_TEST_ROTATED_X2_FOR_X1Y1X2Y2_THETA(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, GIVEN_ANGLE_IN_DEGREES As Double) As Double Dim TEMP_LINE_SEGMENT As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT

TEMP_LINE_SEGMENT = GET_ROTATED_2D_LINE_SEGMENT_FROM_X1Y1X2Y2_DATA_START_POINT_AS_PIVOT(X1, Y1, X2, Y2, GIVEN_ANGLE_IN_DEGREES) GET_TEST_ROTATED_X2_FOR_X1Y1X2Y2_THETA = TEMP_LINE_SEGMENT.X2 End Function 'Public Function GET_TEST_ROTATED_X2_FOR_X1Y1X2Y2_THETA(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, GIVEN_ANGLE_IN_DEGREES As Double) As Double

Public Function GET_TEST_ROTATED_Y2_FOR_X1Y1X2Y2_THETA(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, GIVEN_ANGLE_IN_DEGREES As Double) As Double Dim TEMP_LINE_SEGMENT As SANJOYNATHS_GEOMETRIFYINGTRIGONOMETRY_2D_LINE_SEGMENT

TEMP_LINE_SEGMENT = GET_ROTATED_2D_LINE_SEGMENT_FROM_X1Y1X2Y2_DATA_START_POINT_AS_PIVOT(X1, Y1, X2, Y2, GIVEN_ANGLE_IN_DEGREES) GET_TEST_ROTATED_Y2_FOR_X1Y1X2Y2_THETA = TEMP_LINE_SEGMENT.Y2 End Function 'Public Function GET_TEST_ROTATED_Y2_FOR_X1Y1X2Y2_THETA(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double, GIVEN_ANGLE_IN_DEGREES As Double) As Double