def triangle_address(fx, pt):
fx = np.asarray(fx)<EOL>pt = np.asarray(pt)<EOL>ab = fx[<NUM_LIT:1>] - fx[<NUM_LIT:0>]<EOL>ac = fx[<NUM_LIT:2>] - fx[<NUM_LIT:0>]<EOL>bc = fx[<NUM_LIT:2>] - fx[<NUM_LIT:1>]<EOL>ap = np.asarray([pt_i - a_i for (pt_i, a_i) in zip(pt, fx[<NUM_LIT:0>])])<EOL>r = np.sqrt((ap ** <NUM_LIT:2>).sum(<NUM_LIT:0>))<EOL>unit = <NUM_LIT:1> - r.astype(bool)<EOL>t0 = vector_angle(ab, ac)<EOL>t = vector_angle(ap + [ab_i * unit for ab_i in ab], ab)<EOL>sint = np.sin(t)<EOL>sindt = np.sin(t0 - t)<EOL>q0 = np.sqrt((bc ** <NUM_LIT:2>).sum(<NUM_LIT:0>))          <EOL>beta = vector_angle(-ab, bc)            <EOL>sinGamma = np.sin(math.pi - beta - t0)<EOL>sinBeta  = np.sin(beta)<EOL>r0 = q0 * sinBeta * sinGamma / (sinBeta * sindt + sinGamma * sint)<EOL>return np.asarray([t/t0, r/r0])<EOL>
triangle_address(FX, P) yields an address coordinate (t,r) for the point P in the triangle
defined by the (3 x d)-sized coordinate matrix FX, in which each row of the matrix is the
d-dimensional vector representing the respective triangle vertx for triangle [A,B,C]. The
resulting coordinates (t,r) (0 <= t <= 1, 0 <= r <= 1) address the point P such that, if t gives
the fraction of the angle from vector AB to vector AC that is made by the angle between vectors
AB and AP, and r gives the fraction ||AP||/||AR|| where R is the point of intersection between
lines AP and BC. If P is a (d x n)-sized matrix of points, then a (2 x n) matrix of addresses
is returned.