It is the point of maximal electrostatic potential inside a triangle having a homogeneous surface charge distribution. It's also a point of zero electric field of the same charge distribution, and happens to satisfy the mathematical definition of triangle center. A lot of technical details can be found in the article 'From electrostatic potentials to yet another triangle center' by Hrvoje Abraham and Vjekoslav Kovac. (http://arxiv.org/pdf/1312.3176v2.pdf)
Center is also listed in Kimberling's Encyclopedia of triangle centers under X(5626) = CENTER OF ELECTROSTATIC POTENTIAL. (http://faculty.evansville.edu/ck6/encyclopedia/ETCPart4.html#X5626)
The point is successfully used to improve the stability and speed up the convergence of BEM methods for electrostatic problems.
This repository contains a few routines for numerical calculation of X(5626). Precise routines are written in Wolfram Mathematica, with practical approximation being implemented in C and Python.
A brief documentation for Mathematica functions available in ElectrostaticCenter.nb.
FindElectrostaticLambda[{{ax_,ay_},{bx_,by_},{cx_,cy_}}]
Finds numerical value of lambda parameter of triangle electrostatic center X(5626) based on 2D Cartesian coordinates of triangle vertices. Default value of Precision option is 12 decimal places.
ElectrostaticLine[{{ax_,ay_},{bx_,by_},{cx_,cy_}}, lambda_]
Computes a point on electrostatic line of the triangle based on 2D Cartesian coordinates of triangle vertices and lambda parameter. Returns electrostatic center X(5626) if its lambda is used.
FindElectrostaticCenter2D[{{ax_,ay_},{bx_,by_},{cx_,cy_}}]
Returns electrostatic center X(5626) of triangle defined with 2D Cartesian coordinates of its vertices. Default value of Precision option is 12 decimal places.
FindElectrostaticCenter3D[{{ax_,ay_,az_},{bx_,by_,bz_},{cx_,cy_,cz_}}]
Returns electrostatic center X(5626) of triangle defined with 3D Cartesian coordinates of its vertices. Default value of Precision option is 12 decimal places.
A brief documentation for C functions available in electrostaticCenter.c. These functions use approximate estimation of lambda parameter described in section 6 of the article mentioned in the header of this document. Estimation is implemented in a way which reduces the probability of numerical overflow or underflow.
Computes coordinates of electrostatic center based on 2D Cartesian coordinates of triangle vertices.
Syntax:
int electrostaticCenter2D(double ax, double ay, double bx, double by, double cx, double cy,
double* x, double* y)
Parameters:
Name | Type | Description |
---|---|---|
ax, ay, bx, by, cx, cy | double | 2D Cartesian coordinates of ABC triangle vertices |
x, y | double* | pointers to result variables for 2D Cartesian coordinates of electrostatic center |
Remark:
Performance and return value depend on ELECTROCENTERDEBUG preprocess variable being defined in electrostaticCenter.h.
Return value:
Value | Description |
---|---|
< 0 | If calculation failed and ELECTROCENTERDEBUG is defined. It can vary between -6 and -1 depending on where the problem occurred. |
0 | If ELECTROCENTERDEBUG not defined. |
1 | If calculation is successfully executed and ELECTROCENTERDEBUG is defined. |
Computes coordinates of electrostatic center based on 3D Cartesian coordinates of triangle vertices.
Syntax:
int electrostaticCenter3D(double ax, double ay, double az, double bx, double by, double bz,
double cx, double cy, double cz, double* x, double* y, double* z)
Parameters:
Name | Type | Description |
---|---|---|
ax, ay, az, bx, by, bz, cx, cy, cz | double | 3D Cartesian coordinates of ABC triangle vertices |
x, y, z | double* | pointers to result variables for 3D Cartesian coordinates of electrostatic center |
Remark:
Performance and return value depend on ELECTROCENTERDEBUG preprocess variable being defined in electrostaticCenter.h.
Return value:
Value | Description |
---|---|
< 0 | If calculation failed and ELECTROCENTERDEBUG is defined. It can vary between -8 and -1 depending on where the problem occurred. |
0 | If ELECTROCENTERDEBUG not defined. |
1 | If calculation is successfully executed and ELECTROCENTERDEBUG is defined. |
#include <stdio.h>
#include "..\src\electrostaticCenter.h"
int main(void)
{
double x, y, z;
// compute electrostatic center for triangle ABC
// A(-1,0), B(2,0), C(0,2)
electrostaticCenter2D(-1, 0, 2, 0, 0, 2, &x, &y);
printf("electrostatic center (x, y) = (%lf, %lf)\n", x, y);
// compute electrostatic center for triangle ABC
// A(-1,0,1), B(2,0,2), C(0,2,3)
electrostaticCenter3D(-1, 0, 1, 2, 0, 2, 0, 2, 3, &x, &y, &z);
printf("electrostatic center (x, y, z) = (%lf, %lf, %lf)\n", x, y, z);
return 0;
}
A brief documentation for Python functions available in electrostatic_center.py. These functions use approximate estimation of lambda parameter described in section 6 of the article mentioned in the header of this document. Estimation is implemented in a way which reduces the probability of numerical overflow or underflow.
x, y = electrostatic_center_2d(((ax, ay), (bx, by), (cx, cy)))
Returns electrostatic center of triangle defined as a triplet of 2D Cartesian coordinates of its vertices.
x, y, z = electrostatic_center_3d(((ax, ay, az), (bx, by, bz), (cx, cy, cz)))
Returns electrostatic center of triangle defined as a triplet of 3D Cartesian coordinates of its vertices.
from electrostatic_center import electrostatic_center_2d, electrostatic_center_3d
print('2D electrostatic center (x, y) =', electrostatic_center_2d(((-1, 0), (2, 0), (0, 2))))
print('3D electrostatic center (x, y, z) =', electrostatic_center_3d(((-1, 0, 1), (2, 0, 2), (0, 2, 3))))
All material in this repository is available under MIT license.