vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Mails senden, abrufen und decodieren - ganz easy ;-)  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2024
 
zurück

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

Fortgeschrittene Programmierung
Re: Schittpunkt von 2 linien errechnen? 
Autor: Dirk
Datum: 21.12.06 08:46

Hier mein Code:

Du müsstest noch die Klassen cLine2d und cLocation2d ersetzen.

'               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 Function Intersect(ByRef rLine0 As cLine2d, _
                          ByRef rLine1 As cLine2d) As Boolean
 
  Intersect = (CCW(rLine0.P1, rLine0.P2, rLine1.P1) * _
               CCW(rLine0.P1, rLine0.P2, rLine1.P2)) <= 0 And _
              (CCW(rLine1.P1, rLine1.P2, rLine0.P1) * _
               CCW(rLine1.P1, rLine1.P2, rLine0.P2)) <= 0
 
End Function
 
'***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
Schittpunkt von 2 linien errechnen?1.358Prinzvalium20.12.06 17:38
Re: Schittpunkt von 2 linien errechnen?794ModeratorR@iner20.12.06 17:49
Re: Schittpunkt von 2 linien errechnen?792VBMichi20.12.06 18:32
Re: Schittpunkt von 2 linien errechnen?809Heizer20.12.06 19:13
Re: Schittpunkt von 2 linien errechnen?782Prinzvalium26.12.06 13:28
Re: Schittpunkt von 2 linien errechnen?808Dirk21.12.06 08:46

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-2024 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