'======================================================= ' Class_Lib '======================================================= Const PI = 3.14159265358979 Const P360 = PI * 2 Const P180 = PI Const P90 = PI / 2 Const P270 = ((PI * 3) / 2) '======================================================= ' ExtractFilePath '======================================================= Public Function ExtractFilepath(filename) Dim i, text ExtractFilepath = "" text = Replace(filename, "/", "\") i = InStrRev(text, "\") If (i <= 1) Then Exit Function ExtractFilepath = Left(text, i - 1) End Function '======================================================= ' ExtractFileName '======================================================= Public Function ExtractFileName(filename) Dim i, text ExtractFileName = "" text = Replace(filename, "/", "\") i = InStrRev(text, "\") If (i <= 1) Then Exit Function ExtractFileName = Right(text, Len(text) - i) End Function '======================================================= ' ExtractFileNam '======================================================= Public Function ExtractFileNam(filename) ExtractFileNam = filename text = ExtractFileName(filename) i = InStrRev(text, ".") If i = 0 Then Exit Function ExtractFileNam = Left(text, i - 1) End Function '======================================================= ' ExtractFileExt '======================================================= Public Function ExtractFileExt(filename) ExtractFileExt = "" text = ExtractFileName(filename) i = InStrRev(text, ".") If i = 0 Then Exit Function ExtractFileExt = Right(text, Len(text) - (i - 1)) End Function '======================================================= ' Angle '======================================================= Public Function Angle(P1 As IPoint, P2 As IPoint) As Double Const esp = 0.0000001 Dim dx As Double Dim dy As Double Dim dir As Double Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double x1 = P1.x y1 = P1.y x2 = P2.x y2 = P2.y dx = x2 - x1 dy = y2 - y1 If (Abs(dx) > esp) Then dir = Atn(dy / dx) If ((dx < 0) And (dy < 0)) Then dir = dir + PI If ((dx < 0) And (dy >= 0)) Then dir = dir + PI Else: dir = P270 If (y2 > y1) Then dir = P90 If (Abs(y2 - y1) < esp) Then dir = 0 End If Angle = dir End Function '======================================================================== ' Length '======================================================================== Public Function Length(P1 As IPoint, P2 As IPoint) As Double Dim dx, dy As Double dx = P1.x - P2.x dy = P1.y - P2.y Length = Sqr(dx * dx + dy * dy) End Function '======================================================================== ' RotatePoint '======================================================================== Public Sub RotatePoint(Point As IPoint, Angle As Double) Dim tx, ty As Double tx = (Point.x * Cos(Angle)) - (Point.y * Sin(Angle)) ty = (Point.x * Sin(Angle)) + (Point.y * Cos(Angle)) Point.x = tx Point.y = ty End Sub '======================================================================== ' MovePointToOrigin '======================================================================== Public Sub MovePointToOrigin(Point As IPoint, Origin As IPoint) Point.x = Point.x - Origin.x Point.y = Point.y - Origin.y End Sub '======================================================================== ' MovePointFromOrigin '======================================================================== Public Sub MovePointFromOrigin(Point As IPoint, Origin As IPoint) Point.x = Point.x + Origin.x Point.y = Point.y + Origin.y End Sub '======================================================================== ' Degree '======================================================================== Public Function Degree(Angle As Double) As Double Degree = Angle While (Degree < 0) Degree = Degree + P360 Wend Degree = Degree * 180 / PI End Function '======================================================================== ' Radian '======================================================================== Public Function Radian(Angle As Double) As Double Radian = Angle Radian = Radian Mod 360 If (Radian < 0) Then Radian = Radian + 360 Radian = Radina * PI / 180 End Function '======================================================================== ' R (2 Decimals) '======================================================================== Public Function R(Value As Double) As Double R = Round(Value, 2) End Function '======================================================================== ' Min '======================================================================== Public Function Min(A, b) As Double Min = A If (b < A) Then Min = b End Function