martes, 31 de mayo de 2022

Matriu de m x n a una matriu de dues columnes on la primera és recursiva (resultat a partir de la columna 36 o AJ)

Sub taula()

Dim CantFila As Long
Dim CantCol As Long
Dim c As Single, f As Single, M As Single
M = 1

CantFila = Cells(Rows.Count, 1).End(xlUp).Row
CantCol = Cells(1, Columns.Count).End(xlToLeft).Column

    
For c = 2 To CantCol Step 1
    For f = 2 To CantFila Step 1

        Cells(M, 31).Value = Cells(f, 1).Value
        Cells(M, 32).Value = Cells(1, c).Value
        Cells(M, 33).Value = Cells(f, c).Value
        M = M + 1

    Next f
Next c

End Sub


domingo, 1 de mayo de 2022

Shape detection (square, equilateral triangle and circle)

Three shapes are going to be recognised through a formula that manages the square, the triangle or the circle itself over a relative area to its circumscribed circle.

Then, 

  • if the result of substraction is 36%, the original area is a square
  • if the area resulting is a 58% then the shape is an equilateral triangle
  • Finally, if all the area is substracted and results 0%, the shape is the circle itself.  
See below the details on formulae: 





In addition to this, it is required to define the center from three points at least. Thus, we determine the center. This point is called centroid. The algorith to get
 is https://stackoverflow.com/questions/4103405/what-is-the-algorithm-for-finding-the-center-of-a-circle-from-three-points

From an image, where blue color has been scanned, we can get min and max from x scan and just min from y scan. 
Although we already know which the area should be, we need determining three points at least.

Let's make a revision on PVector in Processing. Once more, Schiffman teaches us how to do it.