* Create direct representations of geometric objects *"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def round(*args): # args are conformal points\n",
" ans = args[0]\n",
" for i in range(1,len(args)):\n",
" ans = ans ^ args[i]\n",
" return(ans)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def flat(*args): # args are conformal points\n",
" return(round(*args) ^ eoo)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def line(p,q): # If q is 3D, line thru p parallel to q returned\n",
" return(flat(p,q))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def plane(p,q,r):\n",
" return(flat(p,q,r))"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def circle(p,q,r):\n",
" return(round(p,q,r))"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def sphere(p,q,r,s):\n",
" return(round(p,q,r,s))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Create dual representations of geometric objects *
"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def dualLine(p, B): # thru point p, orthogonal to 3D bivector B\n",
" return(p < (B*eoo)) # A vector"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def dualPlane(p,n): # n: GA^3 normal vector \n",
" m = normalize(n)\n",
" if isinstance(p,(int, long, float)):\n",
" p = scalar(p) # Python scalar -> GAlgebra scalar\n",
" if (p!=0) and ((p GAlgebra scalar\n",
" if (rho!=0) and ((rho* Geometric operations *"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def translate(object,a3): # a3: 3D vector\n",
" return(1 - a3*eoo/2)*object*(1 + a3*eoo/2)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def rotate(object,itheta):\n",
" return(exp(-itheta/2)*object*exp(itheta/2))"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def invert(p, norm=False): # GACS 513\n",
" ans = -(eo - eoo/2)*p*(eo - eoo/2) \n",
" if norm:\n",
" ans = normalize(ans)\n",
" return(ans)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Reflect point p in hyperplane with normal 3D vector n.\n",
"def reflect(p,n):\n",
" return(-n*p*(n/norm2(n))) "
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Can be considerably simplified: A Covariant Approach ..., 16 \n",
"def dilate(p, alpha, norm = False): # Dilate by alpha (> 0)\n",
" ans = exp(E*ln(alpha)/2)*p*exp(-E*ln(alpha)/2)\n",
" if norm:\n",
" ans = normalize(ans)\n",
" return(ans)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Play *
"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"celltoolbar": "Raw Cell Format",
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}