vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Blitzschnelles Erstellen von grafischen Diagrammen!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Visual-Basic Einsteiger
Re: Mathematisches Problem 
Autor: Dirk
Datum: 26.01.09 07:59

Hier die Funktion CCW (ConterClockWise) für 3 Punkte, die sollte dir helfen. Die Klasse cLocation2d beinhaltet z.B. die x und y coordinate. Du kannst dir dafür auch einen Type anlegen, oder die x,y Werte einzeln übergeben.
'*******************************************************************************
'               1: orientation is counterclockwise or
'                  points are collinear and
'                  rP1 between rP0 and rP2              P0--P1--P2
'              -1: orientation is clockwise or
'                  points are collinear and
'                  rP0 between rP1 and rP2              P1--P0--P2
'               0: points are collinear and
'                  rP2 is between rP1 and rP2           P1--P2--P0
Public Enum tCCW
  CCW_CCW_OR_P1_BETWEEN = 1
  CCW_CW_OR_P0_BETWEEN = -1
  CCW_P2_BETWEEN = 0
End Enum
 
'***Public**********************************************************************
'
'  Procedure:  Function CCW
' Parameters:  rP0, rP1, rP2 all cLocation2d
'     Return:  tCCW
'
'               1: orientation is counterclockwise or
'                  rP1 between rP0 and rP2              P0--P1--P2
'              -1: orientation is clockwise
'                  rP0 between rP1 and rP2              P1--P0--P2
'               0: poins are collinear
'                  rP2 is between rP1 and rP2           P1--P2--P0
'
'Description:  CCW (CounterClockWise) returns orientation of the 3 points on a
'              plane. In case that all points are collinear (on a straight line)
'              see return description.
'
'*******************************************************************************
Public Function CCW( _
    ByRef rP0 As cLocation2d, _
    ByRef rP1 As cLocation2d, _
    ByRef rP2 As cLocation2d _
  ) As tCCW
 
  On Error Resume Next
 
  Dim dx1 As Long, dx2 As Long, dy1 As Long, dy2 As Long
 
  dx1 = rP1.X - rP0.X
  dy1 = rP1.Y - rP0.Y
 
  dx2 = rP2.X - rP0.X
  dy2 = rP2.Y - rP0.Y
 
  If (dx1 * dy2 > dy1 * dx2) Then
    CCW = CCW_CCW_OR_P1_BETWEEN
  ElseIf (dx1 * dy2 < dy1 * dx2) Then
    CCW = CCW_CW_OR_P0_BETWEEN
  ElseIf ((dx1 * dx2) < 0) Or ((dy1 * dy2) < 0) Then
    CCW = CCW_CW_OR_P0_BETWEEN
  ElseIf ((dx1 * dx1 + dy1 * dy1) < (dx2 * dx2 + dy2 * dy2)) Then
    CCW = CCW_CCW_OR_P1_BETWEEN
  Else
    CCW = CCW_P2_BETWEEN
  End If
 
End Function

Gruß
Dirk

--
?Get it right the first time

alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Mathematisches Problem946MichaelG25.01.09 10:35
Re: Mathematisches Problem687Preisser25.01.09 13:31
Re: Mathematisches Problem584Dirk26.01.09 07:59
Re: Mathematisches Problem568Dirk26.01.09 08:11
Re: Mathematisches Problem548MichaelG26.01.09 08:31

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel