'
' Point.Multiply
'
' SELF: {
' ptA, ptB
' }
'
' Returns: Point
'
' Requires: Number.AsPoint, Point.AsNumber
'
' This script uses points a@b to represent numbers of the
' form a + b*e modulo m=2^31 - 1 where e = 2^16. Note that
' e^2 = 2 modulo m. Thus,
'
' a@b * c@d = (a+b*e) * (c+d*e) = ac + (ad+bc)e + bde^2
' = ac + (ade) + (bce) + 2bd modulo m
'
' By further reducing the products ac, ad, bc, bd, and 2bd,
' we can represent the product in the form x + ye, which is
' returned as the point x@y.
'
' ArcView 3.2a
' 4 Jan 2002, WAH @QD
' (c) 2002 Quantitative Decisions
' All rights reserved.
'
' The whole reason for representing numbers modulo 2^31-1 in this
' point form is that direct multiplication can produce values larger
' than 2^52, which will overflow ArcView's double-precision format.
'======================================================================'
ptA = SELF.Get(0)
ptB = SELF.Get(1)
'
' Compute cross-products.
'
ptAC = av.Run("Number.AsPoint",ptA.GetX*ptB.GetX)
ptAD = av.Run("Number.AsPoint",ptA.GetX*ptB.GetY)
ptBC = av.Run("Number.AsPoint",ptA.GetY*ptB.GetX)
ptBD = av.Run("Number.AsPoint",ptA.GetY*ptB.GetY)
'
' Multiply by e.
'
ptAD = (ptAD.GetY*2)@(ptAD.GetX)
ptBC = (ptBC.GetY*2)@(ptBC.GetX)
'
' Multiply by e^2.
'
ptBD = ptBD*(2@2)
'
' Add.
'
ptXY = ptAC+ptAD+ptBC+ptBD
'
' Reduce modulo 2^31-1.
'
n = av.Run("Point.AsNumber",ptXY)
return av.Run("Number.AsPoint",n)
' end of script