ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¸¨ÂI°ÝÃD....(§Ú¥Ø«e±q¥¼¨ì¹Lªº»â°ì)

¦^´_ 12# stillfish00
stillfish00¤j ¶W¼F®`¡A¯u¬O¤Ñ¤~­C~
§Ú¦n¦nªº¬ã¨s¤@¤U¡A¯uªºÁÂÁÂ!   ¬Û«H¥H«á§A¦³»Ý­n¡A§O¤H¤]¤@©w·|À°§Aªº^^~

TOP

¦^´_ 12# stillfish00


¦¬¨ì¤F¡A·PÁ¸U¤À
ªì¨B´ú¸Õ OK

§Ú­Ì¤uµ{³]­p­nºâ¤@¨Ç­±¿n¡B§Î¤ß¡BºD©Ê¯xIx¡B Iy¡BIxy µ¥
µ{¦¡³£¬ODOS®É´ÁFORTRAN¼gªº¡A¦bWIN7¡BWIN8¨t²ÎµLªk°õ¦æ(¶V¨Ó¶V¤£¬Û®e)¡C
­è·QÂରEXCEL VBA¨Ó³B²z¡A¬Ý¨Ó§A¤w¸gÀ°§Ú§¹¦¨²Ä¤@¨B¤F¡A·PÁ¡C
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¦^´_ 10# ML089
¦Û­q¨ç¼Æ
  1. Function PolyArea(rngPoly As Range)
  2.     Dim i As Long, j As Long
  3.     Dim pix As Double, piy As Double
  4.     Dim pjx As Double, pjy As Double
  5.     Dim arPoly, area As Double
  6.         
  7.     arPoly = rngPoly.Value
  8.     If UBound(arPoly, 2) <> 2 _
  9.         Or arPoly(1, 1) <> arPoly(UBound(arPoly), 1) _
  10.         Or arPoly(1, 2) <> arPoly(UBound(arPoly), 2) Then PolyArea = CVErr(xlErrRef): Exit Function
  11.    
  12.     area = 0
  13.     For i = 1 To UBound(arPoly) - 1
  14.         j = i + 1
  15.         pix = arPoly(i, 1): piy = arPoly(i, 2)
  16.         pjx = arPoly(j, 1): pjy = arPoly(j, 2)
  17.         
  18.         area = area + pix * pjy
  19.         area = area - piy * pjx
  20.     Next
  21.     PolyArea = Abs(area) / 2
  22. End Function
½Æ»s¥N½X

TOP

¦^´_ 6# stillfish00

stillfish00¤j ¦n¯«¡A­ì¨Ó¨º¬OC »y¨¥³á!

³ºµM¥i¥H§ï¼g¦¨VBA~¯u¬O¼F®`­C~

¤]ÁÂÁÂML089ªº°Ñ»P^^~

TOP

¦^´_ 6# stillfish00

¤£¦n·N«ä¡A­É¸Óª©¸ê®Æ

stillfish00¤j:
¥i§_½Ð§A¦AÀ°¦£¼g A¡BB¡BCµ¥°Ï°ì­±¿nªº¦Û­q¨ç¼Æ¡A·P®¦¡C
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¦^´_ 5# ui123

stillfish00 ¤jªº¥\¤O°ª±j¡A¨Ï¥Î¦Û­q¨ç¼ÆÀ³¸Ó³Ì¦nªº¤è¦¡

ºô­¶¤¤©Ò­zªº¤èªk¤ñ§ÚÁ¿ªº¦Ò¼{¤èªkÁÙ­n¥¿½T

§PÂ_¤@­ÓÂI¬O§_¦b²³æ¦hÃä§Î¤º³¡
±qµ¹©wÂI¶}©l¡A©¹ÀH«K¤@­Ó¤è¦V¡]¹ê§@®É²ßºD¤ô¥­©¹¥k¡^®g¥X¤@±øµL­­ªø®g½u¡A¬Ý¬Ý¬ï¹L¦h¤Ö±øÃä¡C¦pªG¬ï¹L°¸¼Æ¦¸¡Aªí¥ÜÂI¦b²³æ¦hÃä§Î¥~³¡¡F¦pªG¬ï¹L©_¼Æ¦¸¡Aªí¥ÜÂI¦b²³æ¦hÃä§Î¤º³¡¡C
­n¤p¤ß³B²z®g½u¬ï¹L³»ÂI¡B®g½u»PÃä­«Å|ªº±¡ªp¡C¤]­n¤p¤ß³B²zÂI¦b¦hÃä§ÎÃä¬É¤Wªº±¡ªp¡C
®É¶¡½ÆÂø«×¬° O(N) ¡A N ¬°Â²³æ¦hÃä§Îªº³»ÂI¼Æ¥Ø¡C

§Ú¦A¨Ó¬ã¨s¥i§_¥Î¤½¦¡¨M¸Ñ¡A¦ý·|¤ñVBA¬Ý°_¨Ó§ó½ÆÂø¡C
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¦^´_ 6# stillfish00


    ¹ªÀy¤@¤U¡AC»y¨¥§ï¬°VBA¡A­è¦n¥i¥H°Ñ¦Ò¡AÁÂÁÂ
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¦^´_ 3# stillfish00


  stillfish00¤j´£¨Ñªº¸ê®Æ«Ü§¹¾ã¡AÁÂÁ§A´£¨Ñ¨º»ò§¹¾ãªººô­¶¸ê°T¡C
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2013-11-13 00:27 ½s¿è

¦^´_ 4# ui123
¥L¬OC/C++¼gªº¡A§ï¦¨VBA¤j¬ù¦p¤U
  1. Function pointInPoly(ptx As Double, pty As Double, arPoly) As Boolean
  2.     Dim i As Long, j As Long
  3.     Dim pix As Double, piy As Double
  4.     Dim pjx As Double, pjy As Double
  5.    
  6.     For i = 1 To UBound(arPoly) - 1
  7.         j = i + 1
  8.         pix = arPoly(i, 1): piy = arPoly(i, 2)
  9.         pjx = arPoly(j, 1): pjy = arPoly(j, 2)
  10.         
  11.         '¤£¥]§tÂI¦b¦hÃä§Î½u¤W
  12.         If Not (piy > pty) = (pjy > pty) Then
  13.             If ptx < (pjx - pix) * (pty - piy) / (pjy - piy) + pix Then pointInPoly = Not pointInPoly
  14.         End If
  15.     Next
  16. End Function
½Æ»s¥N½X
§Q¥Î¥L¼g¤@­Ó¦Û­q¨ç¼ÆRegionABC
  1. Function RegionABC(x As Double, y As Double, RegionA As Range, RegionB As Range, RegionC As Range) As String
  2.     '¤£¥]§tÂI¦bABCÃä½t
  3.     If pointInPoly(x, y, RegionA.Value) Then RegionABC = "A": Exit Function
  4.     If pointInPoly(x, y, RegionB.Value) Then RegionABC = "B": Exit Function
  5.     If pointInPoly(x, y, RegionC.Value) Then RegionABC = "C": Exit Function
  6.     RegionABC = "¤£¦bABC"
  7. End Function
½Æ»s¥N½X
¥ý¸É»ôB°ÏªºÂI¡A
¨Ï¥Î¡A¨Ò¦p¦bO4¤½¦¡¥´¤W  "=RegionABC(M4,N4,$C$4:$D$8,$C$10:$D$16,$C$18:$D$22)"

TOP

¦^´_ 2# ML089
ML089¤j~
B°Ïªº´y­z¥i§_¥t¦æ¸ÉÂI(®y¼Ð)³B²z?   ¥i¥Hªº¡A³o¼Ë¤]¤ñ¸û¦X²z¡A¥BABC°ÏµL¥æ¶°
¤]´N¬O»¡¡A¦pªG­è¦n¦b­«Å|ªº½u¤W¡A¨ú¸û¤p¨º¤@­Ó(A<B<C)¡A¨Ò¦p¡A­è¦n¦bA°Ï¤ÎB°Ï¥æ±µ½u¤W¡AºâA°Ïªº
¤U­±¦³¥tªþ¨Ò¤l¡Astillfish00 ¤j»¡ªº¦nÃø¡A³oºØ°ÝÃD¥Î"VBA¨ç¼Æ"¥i¥H¼gªº¥X¨Ó¶Ü?!
ºô¸ô¤W§Ú§ä¤£¨ìVBA¼gªº¨Ò¤l~
¥u¬O§Ú¤]«Ü¦n©_VBA¬O§_¯à¸Ñ¨M¦¹Ãþ°ÝÃD¡A³oºØ°ÝÃD·Pı«Ü²³æ¡A¦ý¦ü¥G¶WÃø§PÂ_ªº!~
¤j®a¥i¥H·Q¤@·Q¡AÁÂÁÂ!

TOP

        ÀR«ä¦Û¦b : ¤H­n¦Û·R¡A¤~¯à·R´¶¤Ñ¤Uªº¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD