{"action":"created","comment":{"url":"https://api.github.com/repos/sympy/sympy/pulls/comments/36583583","id":36583583,"diff_hunk":"@@ -0,0 +1,167 @@\n+from sympy import Symbol\n+from sympy.physics.mechanics import RigidBody, Particle, ReferenceFrame, \\\n+    inertia\n+from sympy.physics.vector import Point, Vector\n+\n+__all__ = ['Body']\n+\n+\n+class Body(RigidBody, Particle):\n+    \"\"\"\n+    A Body which can be connected by joints.\n+\n+    Instances of Body can be connected using specific joints and can further\n+    be used to generate equations of motion. It can be seen as an extension\n+    of already present RigidBody and Particle classes and can inherit from\n+    either of them based on the arguments passed.\n+\n+    Parameters\n+    ---------\n+    name: string\n+        defines the name of the body. It is used as the base for defining body\n+        specific properties.\n+    masscenter : Point (optional)\n+        The point which represents the center of mass of the rigid body.\n+    frame : ReferenceFrame (optional)\n+        The ReferenceFrame which the rigid body is fixed in.\n+    mass : Sympifyable (optional)\n+        The body's mass.\n+    body_inertia : Dyadic (instance of inertia)\n+        The body's inertia about center of mass.\n+\n+    Example:\n+    --------\n+    1. Default behaviour. It creates a RigidBody after defining mass,\n+     masscenter, frame and inertia.\n+\n+    >>> from pydy.bodies import Body\n+    >>> body = Body('name_of_body')\n+\n+    2. Passing attributes of Rigidbody. All the arguments needed to create a\n+     RigidBody can be passed while creating a Body too.\n+\n+    >>> from sympy import Symbol\n+    >>> from sympy.physics.mechanics import ReferenceFrame, Point, inertia\n+    >>> from sympy.physics.mechanics import Body\n+    >>> mass = Symbol('mass')\n+    >>> masscenter = Point('masscenter')\n+    >>> frame = ReferenceFrame('frame')\n+    >>> body_inertia = inertia(frame, 1, 0, 0)\n+    >>> body = Body('name_of_body', masscenter, mass, frame, body_inertia)\n+\n+    3. Creating a Particle. If masscenter and mass are passed, and inertia is\n+     not then a Particle is created.\n+\n+    >>> from sympy import Symbol\n+    >>> from sympy import Point\n+    >>> from sympy.physics.mechanics import Body\n+    >>> mass = Symbol('mass')\n+    >>> masscenter = Point('masscenter')\n+    >>> body = Body('name_of_body', masscenter, mass)\n+\n+    Similarly, A frame can also be passed while creating a Particle.\n+\n+    \"\"\"\n+    def __init__(self, name, masscenter=None, mass=None, frame=None,\n+                 body_inertia=None):\n+\n+        self.parent = None\n+        self.child = None\n+        self.force_list = []\n+        self._counter = 0\n+\n+        if masscenter is None:\n+            self._masscenter = Point(name + '_masscenter')\n+        else:\n+            self._masscenter = masscenter\n+\n+        if mass is None:\n+            _mass = Symbol(name + '_mass')\n+        else:\n+            _mass = mass\n+\n+        if frame is None:\n+            self._frame = ReferenceFrame(name + '_frame')\n+        else:\n+            self._frame = frame\n+\n+        if body_inertia is None and mass is None:\n+            _inertia = (inertia(self._frame, 1, 1, 1), self._masscenter)\n+        else:\n+            _inertia = (body_inertia, self._masscenter)\n+\n+        self._masscenter.set_vel(self._frame, 0)\n+\n+        # If user passes masscenter and mass then a particle is created\n+        # otherwise a rigidbody. As a result a body may or may not have inertia.\n+        if body_inertia is None and mass is not None:\n+            Particle.__init__(self, name, self._masscenter, _mass)\n+        else:\n+            RigidBody.__init__(self, name, self._masscenter, self._frame, _mass, _inertia)\n+\n+    def add_force(self, force_vector, point=None, frame=None):\n+        \"\"\"\n+        Adds force to the body by adding a force vector in form of a tuple\n+        of length 3 and a point on which the force will be applied.\n+\n+        Parameters\n+        ---------\n+        force_vector: A 3-Tuple\n+            Defines the force vector w.r.t frame passed (or Body's frame). The\n+            tuple defines the values of vector in x, y and z directions of the\n+            frame.\n+        point: Point\n+            Defines the point on which the force must be applied.\n+        frame: ReferenceFrame\n+            Defines the frame w.r.t which force vector must be defined.\n+\n+        Example\n+        --------\n+        To add a force of magnitude 1 in y direction on a point at distance of\n+        1 in x direction. All the directions are w.r.t body's frame.\n+\n+        >>> from sympy import Symbol\n+        >>> from sympy.physics.mechanics import Body\n+        >>> body = Body('body')\n+        >>> g = Symbol('g')\n+        >>> body.add_force((body.get_mass() * g, 0, 0), body.get_masscenter())\n+\n+        To define the force_vector w.r.t some other frame, pass the frame as well.\n+\n+        >>> from sympy import Symbol\n+        >>> from sympy.physics.mechanics import Body\n+        >>> parent = Body('parent')\n+        >>> child = Body('child')\n+        >>> g = Symbol('g')\n+        >>> frame = parent.get_frame()\n+        >>> masscenter = child.get_masscenter()\n+        >>> gravity = child.get_mass() * g\n+        >>> body.add_force((gravity, 0, 0), masscenter, frame)\n+\n+        \"\"\"\n+        if point is None:\n+            point = self._masscenter  # masscenter\n+\n+        if frame is None:\n+            frame = self._frame\n+\n+        if not isinstance(force_vector, tuple):\n+            raise TypeError(\"Force vector must be a tuple of length 3\")\n+        else:\n+            force_vector = self._convert_tuple_to_vector(force_vector, frame)\n+        self.force_list.append((point, force_vector))\n+        self._counter += 1\n+\n+    def _convert_tuple_to_vector(self, pos_tuple, frame):","path":"sympy/physics/mechanics/body.py","position":155,"original_position":155,"commit_id":"8087a4152344e79bde6f6fb3fc1c6b3e199dd250","original_commit_id":"8087a4152344e79bde6f6fb3fc1c6b3e199dd250","user":{"login":"moorepants","id":276007,"avatar_url":"https://avatars.githubusercontent.com/u/276007?v=3","gravatar_id":"","url":"https://api.github.com/users/moorepants","html_url":"https://github.com/moorepants","followers_url":"https://api.github.com/users/moorepants/followers","following_url":"https://api.github.com/users/moorepants/following{/other_user}","gists_url":"https://api.github.com/users/moorepants/gists{/gist_id}","starred_url":"https://api.github.com/users/moorepants/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moorepants/subscriptions","organizations_url":"https://api.github.com/users/moorepants/orgs","repos_url":"https://api.github.com/users/moorepants/repos","events_url":"https://api.github.com/users/moorepants/events{/privacy}","received_events_url":"https://api.github.com/users/moorepants/received_events","type":"User","site_admin":false},"body":"This could be a general function for generating vectors. And vectors are not necessarily position vectors so `pos_tuple` doesn't make much sense.","created_at":"2015-08-09T01:49:27Z","updated_at":"2015-08-09T01:49:27Z","html_url":"https://github.com/sympy/sympy/pull/9795#discussion_r36583583","pull_request_url":"https://api.github.com/repos/sympy/sympy/pulls/9795","_links":{"self":{"href":"https://api.github.com/repos/sympy/sympy/pulls/comments/36583583"},"html":{"href":"https://github.com/sympy/sympy/pull/9795#discussion_r36583583"},"pull_request":{"href":"https://api.github.com/repos/sympy/sympy/pulls/9795"}}},"pull_request":{"url":"https://api.github.com/repos/sympy/sympy/pulls/9795","id":41960102,"html_url":"https://github.com/sympy/sympy/pull/9795","diff_url":"https://github.com/sympy/sympy/pull/9795.diff","patch_url":"https://github.com/sympy/sympy/pull/9795.patch","issue_url":"https://api.github.com/repos/sympy/sympy/issues/9795","number":9795,"state":"open","locked":false,"title":"Body class for creating Joints","user":{"login":"sahilshekhawat","id":5890452,"avatar_url":"https://avatars.githubusercontent.com/u/5890452?v=3","gravatar_id":"","url":"https://api.github.com/users/sahilshekhawat","html_url":"https://github.com/sahilshekhawat","followers_url":"https://api.github.com/users/sahilshekhawat/followers","following_url":"https://api.github.com/users/sahilshekhawat/following{/other_user}","gists_url":"https://api.github.com/users/sahilshekhawat/gists{/gist_id}","starred_url":"https://api.github.com/users/sahilshekhawat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sahilshekhawat/subscriptions","organizations_url":"https://api.github.com/users/sahilshekhawat/orgs","repos_url":"https://api.github.com/users/sahilshekhawat/repos","events_url":"https://api.github.com/users/sahilshekhawat/events{/privacy}","received_events_url":"https://api.github.com/users/sahilshekhawat/received_events","type":"User","site_admin":false},"body":"Body class for creating Joints using new JointsMethod.","created_at":"2015-08-08T20:40:31Z","updated_at":"2015-08-09T01:49:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1270338b06f4ab7dd442b9efd2bfead354310a10","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sympy/sympy/pulls/9795/commits","review_comments_url":"https://api.github.com/repos/sympy/sympy/pulls/9795/comments","review_comment_url":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/9795/comments","statuses_url":"https://api.github.com/repos/sympy/sympy/statuses/8087a4152344e79bde6f6fb3fc1c6b3e199dd250","head":{"label":"sahilshekhawat:gsoc15-body-class","ref":"gsoc15-body-class","sha":"8087a4152344e79bde6f6fb3fc1c6b3e199dd250","user":{"login":"sahilshekhawat","id":5890452,"avatar_url":"https://avatars.githubusercontent.com/u/5890452?v=3","gravatar_id":"","url":"https://api.github.com/users/sahilshekhawat","html_url":"https://github.com/sahilshekhawat","followers_url":"https://api.github.com/users/sahilshekhawat/followers","following_url":"https://api.github.com/users/sahilshekhawat/following{/other_user}","gists_url":"https://api.github.com/users/sahilshekhawat/gists{/gist_id}","starred_url":"https://api.github.com/users/sahilshekhawat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sahilshekhawat/subscriptions","organizations_url":"https://api.github.com/users/sahilshekhawat/orgs","repos_url":"https://api.github.com/users/sahilshekhawat/repos","events_url":"https://api.github.com/users/sahilshekhawat/events{/privacy}","received_events_url":"https://api.github.com/users/sahilshekhawat/received_events","type":"User","site_admin":false},"repo":{"id":28129346,"name":"sympy","full_name":"sahilshekhawat/sympy","owner":{"login":"sahilshekhawat","id":5890452,"avatar_url":"https://avatars.githubusercontent.com/u/5890452?v=3","gravatar_id":"","url":"https://api.github.com/users/sahilshekhawat","html_url":"https://github.com/sahilshekhawat","followers_url":"https://api.github.com/users/sahilshekhawat/followers","following_url":"https://api.github.com/users/sahilshekhawat/following{/other_user}","gists_url":"https://api.github.com/users/sahilshekhawat/gists{/gist_id}","starred_url":"https://api.github.com/users/sahilshekhawat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sahilshekhawat/subscriptions","organizations_url":"https://api.github.com/users/sahilshekhawat/orgs","repos_url":"https://api.github.com/users/sahilshekhawat/repos","events_url":"https://api.github.com/users/sahilshekhawat/events{/privacy}","received_events_url":"https://api.github.com/users/sahilshekhawat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sahilshekhawat/sympy","description":"A computer algebra system written in pure Python","fork":true,"url":"https://api.github.com/repos/sahilshekhawat/sympy","forks_url":"https://api.github.com/repos/sahilshekhawat/sympy/forks","keys_url":"https://api.github.com/repos/sahilshekhawat/sympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sahilshekhawat/sympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sahilshekhawat/sympy/teams","hooks_url":"https://api.github.com/repos/sahilshekhawat/sympy/hooks","issue_events_url":"https://api.github.com/repos/sahilshekhawat/sympy/issues/events{/number}","events_url":"https://api.github.com/repos/sahilshekhawat/sympy/events","assignees_url":"https://api.github.com/repos/sahilshekhawat/sympy/assignees{/user}","branches_url":"https://api.github.com/repos/sahilshekhawat/sympy/branches{/branch}","tags_url":"https://api.github.com/repos/sahilshekhawat/sympy/tags","blobs_url":"https://api.github.com/repos/sahilshekhawat/sympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sahilshekhawat/sympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sahilshekhawat/sympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/sahilshekhawat/sympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sahilshekhawat/sympy/statuses/{sha}","languages_url":"https://api.github.com/repos/sahilshekhawat/sympy/languages","stargazers_url":"https://api.github.com/repos/sahilshekhawat/sympy/stargazers","contributors_url":"https://api.github.com/repos/sahilshekhawat/sympy/contributors","subscribers_url":"https://api.github.com/repos/sahilshekhawat/sympy/subscribers","subscription_url":"https://api.github.com/repos/sahilshekhawat/sympy/subscription","commits_url":"https://api.github.com/repos/sahilshekhawat/sympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/sahilshekhawat/sympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/sahilshekhawat/sympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/sahilshekhawat/sympy/issues/comments{/number}","contents_url":"https://api.github.com/repos/sahilshekhawat/sympy/contents/{+path}","compare_url":"https://api.github.com/repos/sahilshekhawat/sympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sahilshekhawat/sympy/merges","archive_url":"https://api.github.com/repos/sahilshekhawat/sympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sahilshekhawat/sympy/downloads","issues_url":"https://api.github.com/repos/sahilshekhawat/sympy/issues{/number}","pulls_url":"https://api.github.com/repos/sahilshekhawat/sympy/pulls{/number}","milestones_url":"https://api.github.com/repos/sahilshekhawat/sympy/milestones{/number}","notifications_url":"https://api.github.com/repos/sahilshekhawat/sympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sahilshekhawat/sympy/labels{/name}","releases_url":"https://api.github.com/repos/sahilshekhawat/sympy/releases{/id}","created_at":"2014-12-17T08:59:26Z","updated_at":"2015-02-12T13:20:38Z","pushed_at":"2015-08-08T20:39:15Z","git_url":"git://github.com/sahilshekhawat/sympy.git","ssh_url":"git@github.com:sahilshekhawat/sympy.git","clone_url":"https://github.com/sahilshekhawat/sympy.git","svn_url":"https://github.com/sahilshekhawat/sympy","homepage":"http://sympy.org/","size":69378,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sympy:master","ref":"master","sha":"e8142083afa20a22905ea58b8827e018b5ae893b","user":{"login":"sympy","id":260832,"avatar_url":"https://avatars.githubusercontent.com/u/260832?v=3","gravatar_id":"","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"repo":{"id":640534,"name":"sympy","full_name":"sympy/sympy","owner":{"login":"sympy","id":260832,"avatar_url":"https://avatars.githubusercontent.com/u/260832?v=3","gravatar_id":"","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sympy/sympy","description":"A computer algebra system written in pure Python","fork":false,"url":"https://api.github.com/repos/sympy/sympy","forks_url":"https://api.github.com/repos/sympy/sympy/forks","keys_url":"https://api.github.com/repos/sympy/sympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sympy/sympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sympy/sympy/teams","hooks_url":"https://api.github.com/repos/sympy/sympy/hooks","issue_events_url":"https://api.github.com/repos/sympy/sympy/issues/events{/number}","events_url":"https://api.github.com/repos/sympy/sympy/events","assignees_url":"https://api.github.com/repos/sympy/sympy/assignees{/user}","branches_url":"https://api.github.com/repos/sympy/sympy/branches{/branch}","tags_url":"https://api.github.com/repos/sympy/sympy/tags","blobs_url":"https://api.github.com/repos/sympy/sympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sympy/sympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sympy/sympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/sympy/sympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sympy/sympy/statuses/{sha}","languages_url":"https://api.github.com/repos/sympy/sympy/languages","stargazers_url":"https://api.github.com/repos/sympy/sympy/stargazers","contributors_url":"https://api.github.com/repos/sympy/sympy/contributors","subscribers_url":"https://api.github.com/repos/sympy/sympy/subscribers","subscription_url":"https://api.github.com/repos/sympy/sympy/subscription","commits_url":"https://api.github.com/repos/sympy/sympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/sympy/sympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/sympy/sympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/sympy/sympy/issues/comments{/number}","contents_url":"https://api.github.com/repos/sympy/sympy/contents/{+path}","compare_url":"https://api.github.com/repos/sympy/sympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sympy/sympy/merges","archive_url":"https://api.github.com/repos/sympy/sympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sympy/sympy/downloads","issues_url":"https://api.github.com/repos/sympy/sympy/issues{/number}","pulls_url":"https://api.github.com/repos/sympy/sympy/pulls{/number}","milestones_url":"https://api.github.com/repos/sympy/sympy/milestones{/number}","notifications_url":"https://api.github.com/repos/sympy/sympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sympy/sympy/labels{/name}","releases_url":"https://api.github.com/repos/sympy/sympy/releases{/id}","created_at":"2010-04-30T20:37:14Z","updated_at":"2015-08-09T00:24:01Z","pushed_at":"2015-08-08T20:40:31Z","git_url":"git://github.com/sympy/sympy.git","ssh_url":"git@github.com:sympy/sympy.git","clone_url":"https://github.com/sympy/sympy.git","svn_url":"https://github.com/sympy/sympy","homepage":"http://sympy.org/","size":152531,"stargazers_count":2269,"watchers_count":2269,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1112,"mirror_url":null,"open_issues_count":1958,"forks":1112,"open_issues":1958,"watchers":2269,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sympy/sympy/pulls/9795"},"html":{"href":"https://github.com/sympy/sympy/pull/9795"},"issue":{"href":"https://api.github.com/repos/sympy/sympy/issues/9795"},"comments":{"href":"https://api.github.com/repos/sympy/sympy/issues/9795/comments"},"review_comments":{"href":"https://api.github.com/repos/sympy/sympy/pulls/9795/comments"},"review_comment":{"href":"https://api.github.com/repos/sympy/sympy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sympy/sympy/pulls/9795/commits"},"statuses":{"href":"https://api.github.com/repos/sympy/sympy/statuses/8087a4152344e79bde6f6fb3fc1c6b3e199dd250"}}}}