{"id":21346649,"url":"https://github.com/manucabral/algepy","last_synced_at":"2025-03-16T03:43:42.991Z","repository":{"id":57674492,"uuid":"480982022","full_name":"manucabral/algepy","owner":"manucabral","description":"Algebra and Analytic Geometry in Python","archived":false,"fork":false,"pushed_at":"2022-04-27T03:49:09.000Z","size":311,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-26T05:06:31.272Z","etag":null,"topics":["algebra","algepy","geometry","math","matplotlib","python","vector"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/algepy/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/manucabral.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-12T21:44:03.000Z","updated_at":"2022-04-27T03:51:59.000Z","dependencies_parsed_at":"2022-08-29T14:30:06.345Z","dependency_job_id":null,"html_url":"https://github.com/manucabral/algepy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manucabral%2Falgepy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manucabral%2Falgepy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manucabral%2Falgepy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/manucabral%2Falgepy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/manucabral","download_url":"https://codeload.github.com/manucabral/algepy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243822277,"owners_count":20353499,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algebra","algepy","geometry","math","matplotlib","python","vector"],"created_at":"2024-11-22T02:09:57.543Z","updated_at":"2025-03-16T03:43:42.971Z","avatar_url":"https://github.com/manucabral.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# algepy\n\u003cdetails\u003e\n  \u003csummary\u003eEnglish readme version, click to spand.\u003c/summary\u003e\n\n## What is Algepy?\nAlgepy is a Python Package that allows you to manipulate vectors, points and planes. It can be useful to calculate or verify the results of your operations.\n\nThis project is still under development and is not fully developed, it may have some bugs or failures.\n\n- [Installation](#i-en)\n- [Vector](#v-en)\n  - [Basic operations](#v-en-ob)\n  - [Opposite](#v-en-o)\n  - [Magnitude](#v-en-mag)\n  - [Direction Cosine](#v-en-dc)\n  - [Angle between two vectors](#v-en-ang)\n  - [Dot product](#v-en-dot)\n  - [Perpendicular](#v-en-per)\n  - [Proyection](#v-en-proy)\n  - [Cross product](#v-en-cross)\n  - [Triple product](#v-en-triple)\n- [Point](#p-en)\n  - [Basic operations](#p-en-ob)\n  - [Midpoint](#p-en-pm)\n  - [Find the vector between two points](#p-en-v)\n- [Plane](#pl-en)\n  - [General equation](#pl-en-eg)\n  - [Symmetric equation](#pl-en-es)\n- [Plot](#g-en)\n  - [Vector](#g-en-v)\n  - [Point](#g-en-p)\n  - [Plane](#g-en-pl)\n- [Contributions](#c-en)\n\n\u003ca name=\"i-en\"\u003e\u003c/a\u003e\n## Installation\n\u003e Using [Python Package Index (PyPI)](https://pypi.org/project/algepy/)\n```bash\npip install algepy\n```\n\u003e Manually\n```bash\ngit clone https://github.com/manucabral/algepy.git\ncd algepy\n```\n\n\u003ca name=\"v-en\"\u003e\u003c/a\u003e\n## Vector\nTo create a vector you simply need to instantiate the Vector class with its components (x, y, z)\n\nBy default it will have 3 dimensions but you can specify the dimension as in the following example.\n```py\nfrom algepy import Vector\nv = Vector(x=1, y=1, z=1)\nu = Vector(x=1, y=1, z=1, dimension=2)\n```\n\n\u003ca name=\"v-en-ob\"\u003e\u003c/a\u003e\n### Basic operations\nTo add and subtract you just have to use the + and - operator, both operations returns a vector.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=2, z=3)\n\u003e\u003e\u003e v = Vector(x=0, y=2, z=5)\n\u003e\u003e\u003e u + v\n(1,4,8)\n\u003e\u003e\u003e u - v\n(1,0,-2)\n```\n\n\u003ca name=\"v-en-o\"\u003e\u003c/a\u003e\n### Opposite\nTo get the opposite of a vector you have to use its `opposite` method, this method returns a new vector.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=2, z=3)\n\u003e\u003e\u003e u.opposite()\n(-1,-2,-3)\n```\n\n\u003ca name=\"v-en-mag\"\u003e\u003c/a\u003e\n### Magnitude\nTo get magnitude of the vector, you have to use `magnitude` method, this method returns a decimal number.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=2, z=3)\n\u003e\u003e\u003e u.magnitude()\n3.7416573867739413\n```\n\n\u003ca name=\"v-en-dc\"\u003e\u003c/a\u003e\n### Direction Cosine\nTo get the direction angles of a vector you have to use the `direction_cosine` method, this method requires that you specify the axis (x, z, y).\n\nThe method returns radians by default but you can change it to degrees using the `degrees` parameter, the same applies with the `decimals` parameter.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e a = Vector(x=2, y=0, z=-2)\n\u003e\u003e\u003e a.direction_cosine(axis='x', degrees=True)\n45.0\n\u003e\u003e\u003e a.direction_cosine(axis='y', degrees=True)\n90.0\n\u003e\u003e\u003e a.direction_cosine(axis='z', degrees=True)\n135.0\n```\n\n\u003ca name=\"v-en-ang\"\u003e\u003c/a\u003e\n### Angle between two vectors\nTo get the angle between two vectors, use the commutative method `angle`.\n\nThe method returns radians by default but you can change it to degrees using the `degrees` parameter, the same applies with the `decimals` parameter.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=1, z=3)\n\u003e\u003e\u003e v = Vector(x=-1, y=0, z=4)\n\u003e\u003e\u003e u.angle(v, degrees=True, decimals=3)\n36.448\n\u003e\u003e\u003e u.angle(v) # resultado en radianes\n0.6361\n```\n\n\u003ca name=\"v-en-dot\"\u003e\u003c/a\u003e\n### Dot product\nTo get the dot product between two vectors, use the * operator (do not confuse this operator with the cross product), this operation returns a scalar number.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=-3, y=5, z=8)\n\u003e\u003e\u003e v = Vector(x=1, y=1, z=1)\n\u003e\u003e\u003e u * v\n10\n```\n\n\u003ca name=\"v-en-per\"\u003e\u003c/a\u003e\n### Perpendicular\nTo know if a vector is perpendicular to another you have to use the `perpendicular` method, this method returns a boolean value (True or False)\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=1, z=3)\n\u003e\u003e\u003e v = Vector(x=-1, y=0, z=4)\n\u003e\u003e\u003e u.perpendicular(v)\nFalse\n```\n\u003ca name=\"v-en-proy\"\u003e\u003c/a\u003e\n### Proyection\nTo get the projection of one vector in the direction of another you have to use the `projection` method, this method returns a list with two vectors.\n\n`w:` main vector (u) projected on another vector (v)\n\n`n:` other vector (v) projected on main vector (u)\n\nThe main vector is the vector to which we apply the `projection` method.\n\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=2, z=1)\n\u003e\u003e\u003e v = Vector(x=0, y=1, z=-1)\n\u003e\u003e\u003e w, n = u.proyection(v)\n\u003e\u003e\u003e w\n(0.0,0.4999999999999999,-0.4999999999999999) # u on v\n\u003e\u003e\u003e n\n(1.0,1.5,1.5) # v on u\n```\n\n\u003ca name=\"v-en-cross\"\u003e\u003c/a\u003e\n### Cross product\nTo get the cross product between two vectors, you must use the `cross` method, this returns the vector resulting from the cross product.\n\nBear in mind that the vector product is not commutative, since if we change the order of the vectors, the direction and the magnitude of the vector product are preserved, but the sense is reversed.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e a = Vector(x=1, y=2, z=3)\n\u003e\u003e\u003e b = Vector(x=0, y=2, z=5)\n\u003e\u003e\u003e v = a.cross(b)\n\u003e\u003e\u003e v\n(4,-5,2) # cross product\n\u003e\u003e\u003e v.perpendicular(a), v.perpendicular(b)\nTrue, True\n```\n\n\u003ca name=\"v-en-triple\"\u003e\u003c/a\u003e\n### Triple product\nTo get the triple product you have to use the `triple` method, this returns a number and isn't commutative.\n\nDefined `u`, `v` and `w`\nWhen using the method on `u`.triple(`v`, `w`) the cross product between `v` and `w` will be applied and then the dot product between `u`(`v`x` w`)\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=2, z=3)\n\u003e\u003e\u003e v = Vector(x=0, y=2, z=5)\n\u003e\u003e\u003e w = Vector(x=0, y=0, z=2)\n\u003e\u003e\u003e u.triple(v, w)\n4\n\u003e\u003e\u003e u * v.cross(w) # equivalent\n```\n\n\u003ca name=\"p-en\"\u003e\u003c/a\u003e\n## Point\nTo create a point you simply need to instantiate the Point class with its (x,y,z) components.\n\nYou can only use 3-dimensional points.\n```py\nfrom algepy import Point\n\u003e\u003e\u003e R = Point(x=1, y=1, z=4)\n\u003e\u003e\u003e S = Point(x=3, y=0, z=2)\n```\n\u003ca name=\"p-en-ob\"\u003e\u003c/a\u003e\n### Basic operations\nTo add and subtract you just have to use the + and - operator, both operations return a point.\n\n\u003ca name=\"p-en-pm\"\u003e\u003c/a\u003e\n### Midpoint\nTo get the midpoint between two points, use the `midpoint` method, it returns a vector with the components of the midpoint.\n```py\nfrom algepy import Point\n\u003e\u003e\u003e r = Point(x=1, y=2, z=3)\n\u003e\u003e\u003e s = Point(x=3, y=-1, z=2)\n\u003e\u003e\u003e r.midpoint(s)\n(2.0,0.5,2.5)\n```\n\n\u003ca name=\"p-en-v\"\u003e\u003c/a\u003e\n### Find the vector between two points\nTo get a vector from two points you have to use the `find_vector` method, this returns a vector formed from the two points.\n\n```py\nfrom algepy import Point\n\u003e\u003e\u003e r = Point(x=1, y=1, z=4)\n\u003e\u003e\u003e s = Point(x=3, y=0, z=2)\n\u003e\u003e\u003e r.find_vector(s)\n(2,-1,-2)\n```\n\u003ca name=\"pl-en\"\u003e\u003c/a\u003e\n## Plane\nTo create a plane we need the normal vector (vector perpendicular to the plane) and some point that belongs to the plane.\n\n```py\n\u003e\u003e\u003e from algepy import Vector, Point, Plane\n\u003e\u003e\u003e n = Vector(x=2, y=-3, z=1)\n\u003e\u003e\u003e p = Point(x=1, y=3, z=1)\n\u003e\u003e\u003e plane = Plane(normal=n, point=p)\n\u003e\u003e\u003e plane\nπ: 2x -3y 1z 6 = 0\n```\n  \nIf we do not pass the normal vector and the default point so these will be null vectors, we can also manually assign the components of the plane by accessing the properties a, b, c and d.\n  \n```py\n\u003e\u003e\u003e from algepy import Vector, Point, Plane\n\u003e\u003e\u003e plane = Plane()\n\u003e\u003e\u003e plane\nπ: 0x 0y 0z 0 = 0\n\u003e\u003e\u003e plane.a = 5\nπ: 5x 0y 0z 0 = 0\n```\n\n\u003ca name=\"pl-en-eg\"\u003e\u003c/a\u003e\n## General equation\nTo get the implicit or general equation of the plane, we simply access the plane object created previously.\n```py\n\u003e\u003e\u003e plane\nπ: 2x -3y 1z 6 = 0\n```\n\n\u003ca name=\"pl-en-es\"\u003e\u003c/a\u003e\n## Symmetric equation\nTo get the segmental equation of the plane we must use the `symmetric_equation` method, for this we need at least to have defined the components of the plane (a, b, c and d).\n\nWe can indicate to the method if we want the result as a fraction or by decimals through the `fraction` parameter\n```py\n\u003e\u003e\u003e from algepy import Vector, Point, Plane\n\u003e\u003e\u003e n = Vector(x=2, y=-3, z=1)\n\u003e\u003e\u003e plane = Plane(normal=n)\n\u003e\u003e\u003e plane.d = 6\n\u003e\u003e\u003e plane.symmetric_equation(fraction=True)\n2x/-6 -3y/-6 1z/-6 = 1\n\u003e\u003e\u003e plane.symmetric_equation(decimals=3)\nx/0.333 y/-0.5 z/0.167 = 1\n```\n\n\u003ca name=\"g-en\"\u003e\u003c/a\u003e\n## Plot\nAlgepy uses pyplot from matplotlib so for this module to work, you need to have this package installed.\n\nFor now the plot only supports 3 dimensions, you can try others dimensions but you will have errors.\n```py\nplot = Plot(name='Example', projection='3d')\nplot.show()\n```\n\n\u003ca name=\"g-en-v\"\u003e\u003c/a\u003e\n### Plot a vector\nTo add a vector to our plot we need to use the `add_vector` method and also have an origin point for the vector.\n\nOnce this is done we can show the graph with the `show` method.\n```py\n  from algepy import Vector, Point, Plot\n  \n  origin = Point(x=0, y=0, z=0)\n  a = Vector(x=1, y=2, z=3)\n  plot = Plot(name='Vector', projection='3d')\n  plot.add_vector(origin=origin, vector=a)\n  plot.show()\n```\n\u003cimg src=\"https://github.com/manucabral/algepy/blob/main/assets/testplot.png?raw=true\" title=\"testplot\"\u003e\n\n\u003ca name=\"g-en-p\"\u003e\u003c/a\u003e\n### Plot a point\nTo add a point to our plot we need to use the `add_point` method.\n\nOnce this is done we can show the graph with the `show` method.\n```py\n  from algepy import Point, Plot\n  \n  p = Point(x=1, y=2, z=3)\n  plot = Plot(name='Point', projection='3d')\n  plot.add_point(point=p, color='red')\n  plot.show()\n```\n\u003cimg src=\"https://github.com/manucabral/algepy/blob/main/assets/testplotpoint.png?raw=true\" title=\"testplotpoint\"\u003e\n\n\u003ca name=\"g-en-pl\"\u003e\u003c/a\u003e\n## Plot a plane\nTo add a plane to our plot we need to use the `add_plane` method.\n\nOnce this is done we can show the graph with the `show` method.\n```py\n  from algepy import Vector, Point, Plane\n \n  n = Vector(x=2, y=-3, z=1)\n  p = Point(x=1, y=3, z=1)\n  plane = Plane(normal=n, point=p)\n  plot = Plot(projection='3d', range=[-5, 5])\n  plot.add_plane(plane=plane, color='red')\n  plot.show()\n```\n\u003cimg src=\"https://github.com/manucabral/algepy/blob/main/assets/plane.png?raw=true\" title=\"testplotplane\"\u003e\n\n\u003ca name=\"c-en\"\u003e\u003c/a\u003e\n## Contributions\nAll contributions, reports or bug fixes and ideas are welcome. You can go to the issues section and provide your help.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eVersión español, click para expander.\u003c/summary\u003e\n\n## ¿Qué es algepy?\nAlgepy es una libreria de python que te permite manipular vectores de hasta 3 dimensiones, te puede ser útil para calcular o verificar los resultados de tus operaciones.\n\nEste proyecto todavía se encuentra en desarrollo y no está completamente desarrollado, puede tener algunos bugs o fallos.\n\n- [Instalación](#i-es)\n- [Vector](#v-es)\n  - [Operaciones básicas](#v-es-ob)\n  - [Opuesto](#v-es-o)\n  - [Módulo o norma](#v-es-mag)\n  - [Ángulos directores](#v-es-dc)\n  - [Ángulo entre dos vectores](#v-es-ang)\n  - [Producto escalar](#v-es-dot)\n  - [Perpendicularidad](#v-es-per)\n  - [Proyección de vectores](#v-es-proy)\n  - [Producto vectorial](#v-es-cross)\n  - [Producto mixto](#v-es-triple)\n- [Punto](#p-es)\n  - [Operaciones básicas](#p-es-ob)\n  - [Punto medio](#p-es-pm)\n  - [Vector a partir de dos puntos](#p-es-v)\n- [Plano](#pl-es)\n  - [Ecuación general](#pl-es-eg)\n  - [Ecuación segmentaria](#pl-es-es)\n- [Gráfico](#g-es)\n  - [Vector](#g-es-v)\n  - [Punto](#g-es-p)\n  - [Plano](#g-es-pl)\n- [Contribuciones](#c-es)\n\n\u003ca name=\"i-es\"\u003e\u003c/a\u003e\n## Instalación\n\u003e Utilizando [Python Package Index (PyPI)](https://pypi.org/project/algepy/)\n```bash\npip install algepy\n```\n\u003e Manualmente\n```bash\ngit clone https://github.com/manucabral/algepy.git\ncd algepy\n```\n\n\u003ca name=\"v-es\"\u003e\u003c/a\u003e\n## Vector\nPara definir un vector simplemente necesitas instanciar la clase Vector con sus componentes (x, y, z)\n\nPor defecto tendrá 3 dimensiones pero puedes especificarle la dimensión como en el siguiente ejemplo.\n```py\nfrom algepy import Vector\nv = Vector(x=1, y=1, z=1)\nu = Vector(x=1, y=1, z=1, dimension=2) # ignorará el eje z\n```\n\n\u003ca name=\"v-es-ob\"\u003e\u003c/a\u003e\n### Operaciones básica\nPara sumar y restar solamente tienes que utilizar el operador + y -, las dos operaciones devuelve un vector.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=2, z=3)\n\u003e\u003e\u003e v = Vector(x=0, y=2, z=5)\n\u003e\u003e\u003e u + v\n(1,4,8)\n\u003e\u003e\u003e u - v\n(1,0,-2)\n```\n\n\u003ca name=\"v-es-o\"\u003e\u003c/a\u003e\n### Opuesto\nPara obtener el opuesto de un vector hay que utilizar su método `opposite`, este método devuelve un nuevo vector.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=2, z=3)\n\u003e\u003e\u003e u.opposite()\n(-1,-2,-3)\n```\n\n\u003ca name=\"v-es-mag\"\u003e\u003c/a\u003e\n### Módulo o norma\nPara obtener el módulo o la norma del vector hay que utilizar su método `magnitude`, este método devuelve un número decimal.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=2, z=3)\n\u003e\u003e\u003e u.magnitude()\n3.7416573867739413\n```\n\n\u003ca name=\"v-es-dc\"\u003e\u003c/a\u003e\n### Ángulos directores\nPara obtener los ángulos directores de un vector hay que utilizar el método `direction_cosine`, este método requiere que le especifiques el eje obligatoriamente (x, z,  y).\n\nEl método devuelve por defecto en radianes pero lo puedes cambiar a grados mediante el parámetro `degrees`, aplica lo mismo con el parámetro `decimals`.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e a = Vector(x=2, y=0, z=-2)\n\u003e\u003e\u003e a.direction_cosine(axis='x', degrees=True) # ángulo director respecto al eje x\n45.0\n\u003e\u003e\u003e a.direction_cosine(axis='y', degrees=True) # ángulo director respecto al eje y\n90.0\n\u003e\u003e\u003e a.direction_cosine(axis='z', degrees=True) # ángulo director respecto al eje z\n135.0\n```\n\n\u003ca name=\"v-es-ang\"\u003e\u003c/a\u003e\n### Ángulo entre dos vectores\nPara obtener el ángulo que se forma entre dos vectores hay que utilizar el método conmutativo `angle`.\n\nEl método devuelve por defecto en radianes pero lo puedes cambiar a grados mediante el parámetro `degrees`, aplica lo mismo con el parámetro `decimals`.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=1, z=3)\n\u003e\u003e\u003e v = Vector(x=-1, y=0, z=4)\n\u003e\u003e\u003e u.angle(v, degrees=True, decimals=3) # resultado en grados con 3 decimales\n36.448\n\u003e\u003e\u003e u.angle(v) # resultado en radianes\n0.6361\n```\n\n\u003ca name=\"v-es-dot\"\u003e\u003c/a\u003e\n### Producto escalar\nPara obtener el producto escalar entre dos vectores hay que utilizar el operador * (no confundir este operador con el producto vectorial) esta operación devuelve un número escalar.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=-3, y=5, z=8)\n\u003e\u003e\u003e v = Vector(x=1, y=1, z=1)\n\u003e\u003e\u003e u * v\n10\n```\n\n\u003ca name=\"v-es-per\"\u003e\u003c/a\u003e\n### Perpendicularidad\nPara saber si un vector es perpendicular a otro hay que utilizar el método `perpendicular`, este método devuelve un valor booleano (True o False)\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=1, z=3)\n\u003e\u003e\u003e v = Vector(x=-1, y=0, z=4)\n\u003e\u003e\u003e u.perpendicular(v)\nFalse\n```\n\u003ca name=\"v-es-proy\"\u003e\u003c/a\u003e\n### Proyección de vectores\nPara obtener la proyección de un vector en la dirección de otro hay que utilizar el método `projection`, este método devuelve una lista con dos vectores.\n\n`w:` vector principal (u) proyectado en otro vector (v)\n\n`n:` otro vector (v) proyectado en el vector principal (u)\n\nEl vector principal es el vector al que le aplicamos el método `projection`.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=2, z=1)\n\u003e\u003e\u003e v = Vector(x=0, y=1, z=-1)\n\u003e\u003e\u003e w, n = u.proyection(v)\n\u003e\u003e\u003e w\n(0.0,0.4999999999999999,-0.4999999999999999) # vector u proyectado en v\n\u003e\u003e\u003e n\n(1.0,1.5,1.5) # vector v proyectado en u\n```\n\n\u003ca name=\"v-es-cross\"\u003e\u003c/a\u003e\n### Producto vectorial\nPara obtener el producto vectorial entre dos vectores hay que utilizar el método `cross`, este método devuelve el vector resultado del producto vectorial.\n\nTener en cuenta que el producto vectorial no es conmutativo, ya que si cambiamos el orden de los vectores se conservan la dirección y el módulo del producto vectorial pero se invierte el sentido.\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e a = Vector(x=1, y=2, z=3)\n\u003e\u003e\u003e b = Vector(x=0, y=2, z=5)\n\u003e\u003e\u003e v = a.cross(b)\n\u003e\u003e\u003e v\n(4,-5,2) # producto vectorial\n\u003e\u003e\u003e v.perpendicular(a), v.perpendicular(b)\nTrue, True\n```\n\n\u003ca name=\"v-es-triple\"\u003e\u003c/a\u003e\n### Producto mixto\nPara obtener el producto mixto hay que utilizar el método `triple`, este método devuelve un escalar y no es conmutativo así que hay que tener en cuenta lo siguiente.\n\nDefinidos `u`, `v` y `w`\nCuando se utiliza el método en `u`.triple(`v`,`w`) se aplicará primero el producto vectorial entre `v` y `w` para después calcular el producto escalar `u`(`v`x` w`)\n\n```py\n\u003e\u003e\u003e from algepy import Vector\n\u003e\u003e\u003e u = Vector(x=1, y=2, z=3)\n\u003e\u003e\u003e v = Vector(x=0, y=2, z=5)\n\u003e\u003e\u003e w = Vector(x=0, y=0, z=2)\n\u003e\u003e\u003e u.triple(v, w)\n4\n\u003e\u003e\u003e u * v.cross(w) # equivalente\n```\n\n\u003ca name=\"p-es\"\u003e\u003c/a\u003e\n## Punto\nPara definir un punto simplemente necesitas instanciar la clase Point con sus componentes (x, y, z).\n\nPor ahora solamente puedes utilizar puntos de 3 dimensiones.\n```py\nfrom algepy import Point\n\u003e\u003e\u003e R = Point(x=1, y=1, z=4)\n\u003e\u003e\u003e S = Point(x=3, y=0, z=2)\n```\n\u003ca name=\"p-es-ob\"\u003e\u003c/a\u003e\n### Operaciones básicas\nPara sumar y restar solamente tienes que utilizar el operador + y -, las dos operaciones devuelve un punto.\n\n\u003ca name=\"p-es-pm\"\u003e\u003c/a\u003e\n### Punto medio\nPara obtener el punto medio entre dos puntos hay que utilizar el método `midpoint`, este devuelve un vector con los componentes del punto medio.\n```py\nfrom algepy import Point\n\u003e\u003e\u003e r = Point(x=1, y=2, z=3)\n\u003e\u003e\u003e s = Point(x=3, y=-1, z=2)\n\u003e\u003e\u003e r.midpoint(s)\n(2.0,0.5,2.5)\n```\n\n\u003ca name=\"p-es-v\"\u003e\u003c/a\u003e\n### Vector a partir de dos puntos\nPara obtener un vector a partir de dos puntos hay que utilizar el método `find_vector`, este devuelve un vector formado a partir de los dos puntos.\n\n```py\n\u003e\u003e\u003e from algepy import Point\n\u003e\u003e\u003e r = Point(x=1, y=1, z=4)\n\u003e\u003e\u003e s = Point(x=3, y=0, z=2)\n\u003e\u003e\u003e r.find_vector(s)\n(2,-1,-2)\n```\n  \n\u003ca name=\"pl-es\"\u003e\u003c/a\u003e\n## Plano\nPara crear un plano necesitamos el vector normal (vector perpendicular al plano) y algún punto que pertenezca al plano.\n\n```py\n\u003e\u003e\u003e from algepy import Vector, Point, Plane\n\u003e\u003e\u003e n = Vector(x=2, y=-3, z=1)\n\u003e\u003e\u003e p = Point(x=1, y=3, z=1)\n\u003e\u003e\u003e plano = Plane(normal=n, point=p)\n\u003e\u003e\u003e plano\nπ: 2x -3y 1z 6 = 0\n```\n  \nSi no le pasamos el vector normal y el punto por defecto estos serán vectores nulos, también podemos asignarle manualmente los componentes del plano accediendo a las propiedades a, b, c y d.\n  \n```py\n\u003e\u003e\u003e from algepy import Vector, Point, Plane\n\u003e\u003e\u003e plano = Plane()\n\u003e\u003e\u003e plano\nπ: 0x 0y 0z 0 = 0\n\u003e\u003e\u003e plano.a = 5\nπ: 5x 0y 0z 0 = 0\n```\n\n\u003ca name=\"pl-es-eg\"\u003e\u003c/a\u003e\n## Ecuación general\nPara obtener la ecucación implícita o general del plano simplemente accedemos al objeto plano creado anteriormente.\n```py\n\u003e\u003e\u003e plano\nπ: 2x -3y 1z 6 = 0\n```\n\n\u003ca name=\"pl-es-es\"\u003e\u003c/a\u003e\n## Ecuación segmentaria\nPara obtener la ecucación segmentaria del plano hay que utilizar el método `symmetric_equation`, para esto necesitamos al menos tener definido los componentes del plano (a, b, c y d).\n\nAl método le podemos indicar si el resultado lo queremos como fracción o por decimales mediante el parámetro `fraction`\n```py\n\u003e\u003e\u003e from algepy import Vector, Point, Plane\n\u003e\u003e\u003e n = Vector(x=2, y=-3, z=1)\n\u003e\u003e\u003e plano = Plane(normal=n)\n\u003e\u003e\u003e plano.d = 6\n\u003e\u003e\u003e plano.symmetric_equation(fraction=True)\n2x/-6 -3y/-6 1z/-6 = 1\n\u003e\u003e\u003e plano.symmetric_equation(decimals=3)\nx/0.333 y/-0.5 z/0.167 = 1\n```\n \n\u003ca name=\"g-es\"\u003e\u003c/a\u003e\n## Gráfico\nAlgepy utiliza pyplot de matplotlib así que para que este módulo te funcione necesitas tener instalado este paquete.\n\nPor ahora el gráfico solamente soporta 3 dimensiones, puedes intentar con otras pero corres el riesgo de obtener varios errores.\n```py\ngrafico = Plot(name='Ejemplo', projection='3d')\ngrafico.show()\n```\n\u003ca name=\"g-es-v\"\u003e\u003c/a\u003e\n### Gráfico de un vector\nPara agregar un vector a nuestro gráfico necesitamos utilizar el método `add_vector` y además tener un punto de origen para el vector.\n\nUna vez realizado esto podemos mostrar el gráfico con el método `show`\n\n```py\nfrom algepy import Vector, Point, Plot\n  \n  origen = Point(x=0, y=0, z=0)\n  a = Vector(x=1, y=2, z=3)\n  grafico = Plot(name='Vector', projection='3d')\n  grafico.add_vector(origin=origen, vector=a)\n  grafico.show()\n```\n\u003cimg src=\"https://github.com/manucabral/algepy/blob/main/assets/testplot.png?raw=true\" title=\"testplot\"\u003e\n\n\u003ca name=\"g-es-p\"\u003e\u003c/a\u003e\n### Gráfico de un punto\nPara agregar un punto a nuestro gráfico necesitamos utilizar el método `add_point`\n\nUna vez realizado esto podemos mostrar el gráfico con el método `show`\n```py\n  from algepy import Point, Plot\n  p = Point(x=1, y=2, z=3)\n  grafico = Plot(name='Punto', projection='3d')\n  grafico.add_point(point=p, color='red')\n  grafico.show()\n```\n\u003cimg src=\"https://github.com/manucabral/algepy/blob/main/assets/testplotpoint.png?raw=true\" title=\"testplotpoint\"\u003e\n\n\u003ca name=\"g-es-pl\"\u003e\u003c/a\u003e\n## Gráfico de un plano\nPara agregar un plano a nuestro gráfico necesitamos utilizar el método `add_plane`\n\nUna vez realizado esto podemos mostrar el gráfico con el método `show`\n```py\n  from algepy import Vector, Point, Plane\n \n  n = Vector(x=2, y=-3, z=1)\n  p = Point(x=1, y=3, z=1)\n  plano = Plane(normal=n, point=p)\n  grafico = Plot(projection='3d', range=[-5, 5])\n  grafico.add_plane(plane=plano, color='red')\n  grafico.show()\n```\n\u003cimg src=\"https://github.com/manucabral/algepy/blob/main/assets/plane.png?raw=true\" title=\"testplotplane\"\u003e\n\n\u003ca name=\"c-es\"\u003e\u003c/a\u003e\n## Contribución\nTodas las contribuciones, reportes o arreglos de bugs e ideas es bienvenido. Para esto puedes dirigirte al apartado de issues y aportar tu ayuda.\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanucabral%2Falgepy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanucabral%2Falgepy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanucabral%2Falgepy/lists"}