├── LICENSE ├── README.md ├── how-far-can-we-throw a ball on jupiter" ├── how far can we throw a ball on jupiter.ipynb └── readme.md ├── particle-physcis' ├── README.md ├── plotting a trajectory of a particle.ipynb └── projectile example.py └── solar-system" ├── IMG_20200831_123930.jpg ├── Readme.md ├── Screenshot (32).png ├── rotaional-motion-of-planets" ├── Screenshot (31).png ├── rotaional-motion-of-planets.css └── rotaional-motion-of-planets.html ├── solar-system-from-2010-2020.css ├── solar-system-from-2010-2020.html ├── solar-system-from-2010-2020.js ├── solar-system.css └── solar-system.html /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Aman Anand 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # coding-for--physics 2 | 3 | ## 📌 Introduction 4 | 5 | In todays world full of computing and technology, scientists utilise the vast power available to them to help accelerate their research. 6 | Programming is extremely important in almost every area of physics. Not every physicist has to be an expert programmer, but many are, and virtually all physicists are at least competent programmers. 7 | In most experiments, the process of data analysis is complex enough to require some programming. More importantly, in many situations, the best (or only) way of telling whether your results are consistent with any given model is to simulate the experiment.so its a collection of codes simulating real world phenomenons or performing computation and much more .This is a place to find or add any new script that can make learning physics much easier and more efficient for you, as a Developer,it's our goal to make solve real world problems by coding . 8 | 9 | 10 | 11 | 12 | ## 📌 Here’s Why You Should Be Coding In Your Physics Course 13 | 14 | like data science, Physics too involves a lot of data analysis. They deal with nuclear data from detectors and astronomical data from telescopes to perform all sorts of analysis and studies needed. So they too need to upskill themselves with programming, at least with the very basic languages useful to them for analysis like Matlab and Python. 15 | If there is someone in this background of Physics who does not know programming, he is really lagging a big time in his field. Even if they think that they know the theory and practical behind their subject of interest, programming does come in handy to for a number of reasons. 16 | 17 | ## 💥 How to Contribute? 18 | 19 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) 20 | [![Open Source Love svg2](https://badges.frapsoft.com/os/v2/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/) 21 | 22 | - Take a look at the Existing issues or create your own Issues! 23 | - Wait for the Issue to be assigned to you after which you can start working on it. 24 | - Fork the Repo and create a Branch for any Issue that you are working upon. 25 | - Create a Pull Request which will be promptly reviewed and suggestions would be added to improve it. 26 | - Add Screenshots to help us know what this Script is all about. 27 | 28 | ## 💻 Languages used in this project 29 | 30 | [![PyPI pyversions](https://img.shields.io/pypi/pyversions/ansicolortags.svg)](https://pypi.python.org/pypi/ansicolortags/) 31 | [![ForTheBadge built-with-science](http://ForTheBadge.com/images/badges/built-with-science.svg)](https://GitHub.com/Naereen/) 32 | [![forthebadge](https://forthebadge.com/images/badges/made-with-javascript.svg)](https://forthebadge.com) 33 | 34 | 35 | ## ❤️ Project Admin 36 | 37 | | 38 | **[Aman Anand]** 39 | -------------------------------------------------------------------------------- /how-far-can-we-throw a ball on jupiter"/how far can we throw a ball on jupiter.ipynb: -------------------------------------------------------------------------------- 1 | {"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"how far can we throw a ball on jupiter","provenance":[{"file_id":"11jjjglbOXUWUBeZBASd0itUkIcL6rME_","timestamp":1598859562901}],"private_outputs":true},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"cell_type":"markdown","metadata":{"id":"C0l9uRQg8QiE","colab_type":"text"},"source":["# HOW FAR CAN WE THROW A BALL ON JUPITER?"]},{"cell_type":"markdown","metadata":{"id":"NuYyp0f5vV9a","colab_type":"text"},"source":["# - Acceleration due to Gravity on other planets\n","\n"," You can use the internet to get values for the masses and radii of the planets, be careful about units! equations will expect meters and kilograms...\n","\n","Here, I want to use a loop to work out 'g' for each planet using its mass and radius and plot the trajectories at a fixed angle. \n","\n","I will start off with the values Earth\n"]},{"cell_type":"code","metadata":{"id":"b8T7nkS8ux6N","colab_type":"code","cellView":"both","colab":{}},"source":["# EDIT THIS ONE...\n","import numpy as np\n","\n","# planet mass in kg\n","# planet radius in m\n","# you can use the 'e' notation: a*(10^b) == a e b\n","masses = np.array(5.972e24, ???, ???, ???)\n","radii = np.array(6.371e6, ???, ???, ???)\n","G = 6.674e-11\n","names =('Earth', ???, ???, ???)\n","\n","g = (-G * masses / (radii**2))\n","\n","for i in len(???):\n"," print ('Acceleration due to gravity at the surface of {a} is {b} m/s^2'.format(a=names[?], b=g[?]))"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"0AwbA9fP6-a7","colab_type":"text"},"source":["I've copied the above cell so you can edit your code without breaking the original above:"]},{"cell_type":"code","metadata":{"id":"0h-52BQj7HFj","colab_type":"code","colab":{}},"source":["# KEEP THIS ONE AS BACKUP IN CASE YOU NEED IT!\n","import numpy as np\n","\n","# planet mass in kg\n","# planet radius in m\n","# you can just use the 'e' notation: a*(10**b) == a e b\n","\n","masses = np.array(5.972e24)\n","radii = np.array(6.371e6)\n","G = 6.674e-11\n","names = ['Earth']\n","\n","g = (-G * masses / (radii**2))\n","\n","\n","print ('Acceleration due to gravity at the surface of {a} is {b} m/s^2'.format(a=names, b=g))"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"5N-jtb7eyppU","colab_type":"text"},"source":["Hopefully, when you run your print statement, you have a list of values like this (feel free to add more planets if you like, or make up your own):\n","\n","![alt text](https://i.imgur.com/cnL6XGq.png)"]},{"cell_type":"markdown","metadata":{"id":"gjWuhpl24FIv","colab_type":"text"},"source":["# - Plotting trajectories on different planets\n","\n","Now I want to plot a projectile launced at *45* degrees on each of the planets. \n","\n","Be careful when using the values of g , make sure you use the right sign in the right place."]},{"cell_type":"code","metadata":{"id":"bzxfTx4a6ArN","colab_type":"code","colab":{}},"source":["# EDIT THIS ONE...\n","# I'm assuming you've already executed the previous cell...\n","\n","import matplotlib.pyplot as plt\n","\n","v_i = 100 \n","a_x = 0\n","\n","angle = 60\n","\n","\n","# lets loop through each of your planets and pick g at each point, as opposed to 'angles[i]\n","for i in range(len(names)):\n"," \n"," # get the timestamps for each projectile:\n"," t_max = 2 * v_i * np.sin(np.deg2rad(angle)) / -g\n"," t_step = 0.01\n"," timestamps = np.arange(0, t_max, t_step)\n"," \n"," # we then work out the x/y coordinates of our projectile at each timestamp for that angle\n"," x = v_i * timestamps * np.cos(np.deg2rad(angle)) + (0.5 * a_x * timestamps ** 2)\n"," y = v_i * timestamps * np.sin(np.deg2rad(angle)) + (0.5 * g * timestamps ** 2)\n"," \n"," plt.plot(x, y, label = names[i])\n","\n","plt.show()"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"Z-woGRRpiA20","colab_type":"text"},"source":["Below is a copy of the code, use it to practice your answer and leave the cell above so you have something to reference."]},{"cell_type":"code","metadata":{"id":"8YBnZkV6h4PQ","colab_type":"code","colab":{}},"source":["# KEEP THIS ONE AS BACKUP INCASE YOU NEED IT!\n","# I'm assuming you've already executed the previous cell...\n","\n","import matplotlib.pyplot as plt\n","\n","v_i = 100 \n","a_x = 0\n","\n","angle = 60\n","\n","\n","# lets loop through each of your planets and pick g at each point, as opposed to 'angles[i]\n","for i in range(len(names)):\n"," \n"," # get the timestamps for each projectile:\n"," t_max = 2 * v_i * np.sin(np.deg2rad(angle)) / -g\n"," t_step = 0.01\n"," timestamps = np.arange(0, t_max, t_step)\n"," \n"," # we then work out the x/y coordinates of our projectile at each timestamp for that angle\n"," x = v_i * timestamps * np.cos(np.deg2rad(angle)) + (0.5 * a_x * timestamps ** 2)\n"," y = v_i * timestamps * np.sin(np.deg2rad(angle)) + (0.5 * g * timestamps ** 2)\n"," \n"," plt.plot(x, y, label = names[i])\n","\n","plt.show()"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"s6zcUhrUns8K","colab_type":"text"},"source":["Using the four planets I showed above, your plot should look something like this:\n","\n","![alt text](https://i.imgur.com/pmXGlNs.png)"]},{"cell_type":"markdown","metadata":{"id":"JaQ0oYLQmxgp","colab_type":"text"},"source":["# - Let's get real\n","\n","So by now we're plotting trajectories of objects on different planets, but our starting velocity has always been 100m/s, is that realistic?\n","\n","Well, according to [Wikipedia](https://en.wikipedia.org/wiki/Aroldis_Chapman), the fastest Baseball pitch ever recorded was 169 km/hr, or 46.9 m/s, under half our initial condition!\n","\n","It's probably safe to assume that the average human couldn't throw a ball faster than half of this, so let's place our initial velocity at 20 m/s.\n","\n","\n","\n","For a) all i need to change the initial velocity, But for part b) we need to save the maximum distance during the plotting loop and use the formatted print statements to see what the answers are:"]},{"cell_type":"code","metadata":{"id":"HOsQFHfnmzRr","colab_type":"code","colab":{}},"source":["# EDIT THIS ONE!\n","# put something like this *outside* your plot loop from Q2\n","\n","max_distance = ???\n","\n","# Put something like this *inside* your plot loop:\n","\n","max_distance.append(x[???])\n","\n","# Then something like this after the plt.show() command, or in a separate cell underneath:\n","\n","for i in range(len(???)):\n"," print ('Projectile launched from planet {a} reached {b} meters'.format(a=names[???], b=(max_distance[???])))"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"kp1ygDJInvjq","colab_type":"code","colab":{}},"source":["# KEEP THIS ONE AS BACKUP INCASE YOU NEED IT!\n","# put something like this *outside* your plot loop from Q2\n","\n","max_distance = ???\n","\n","# Put something like this *inside* your plot loop:\n","\n","max_distance.append(x[???])\n","\n","# Then something like this after the plt.show() command, or in a separate cell underneath:\n","\n","for i in range(len(???)):\n"," print ('Projectile launched from planet {a} reached {b} meters'.format(a=names[???], b=(max_distance[???])))"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"IRXNTIQuor0L","colab_type":"text"},"source":["In this case you'll need to replace the '???' to something sensible. Here are the target results:\n","\n","![alt text](https://i.imgur.com/zRBVZkT.png)"]},{"cell_type":"markdown","metadata":{"id":"D_wbu7kdqyoC","colab_type":"text"},"source":["# Q4 - Why are we doing this?\n","\n","You might be wondering why anyone would bother doing this, when we already know the equations of motion and could easily have worked out these results by hand in just a few seconds...\n","\n","Well, you could imagine that our primitave projectile model can become much more complicated if we started to increase the 'realism' of our simulation. We could add:\n","\n","* Air resistance\n","* Bouncing\n","* Additional forces at launch\n","* 2D or even 3D force vectors\n","* Multiple projectiles\n","* A complex surface for the projectile to encounter\n","* Projectiles that aren't point particles, e.g. something that has a shape\n","* Material properties of the projectile/bouncing etc\n","\n","And before you know it, we could be simulating:\n","\n","* A multistage rocket en-route to Mars\n","* An explosive gas reaching thousands of degrees\n","* Complex astrophysics of objects falling into black holes\n","\n","In every single case, a vast majority of the code will be made of the simple building blocks For anyone aiming to study: Physics, Astronomy, Engineering, Biology, Chemistry, Materials Science, Geography, Psychology or any other science at a graduate level, a basic understanding of programming with a Physics mindset will vastly improve your ability to model and understand your system.\n","\n","we also use programming to *analyse* data where we don't fully know the physics. Instead of using the laws of kinematics to plot trajectories, we might be *given* some noisy trajectories and be asked to figure out the initial conditions. I imagine NASA and Spacex do this for every single launch so that their rockets can be better and more efficient with each successful launch. Even in the ones that fail, it is critical to understand why.\n"]},{"cell_type":"markdown","metadata":{"id":"6XRHqGbc1Yp8","colab_type":"text"},"source":["# Answers:\n","\n","Hopefully you haven't just scrolled down until you found this....\n","\n","**Q1** Printing various accelerations due to gravity:\n"]},{"cell_type":"code","metadata":{"id":"l-urs0m01kUe","colab_type":"code","colab":{}},"source":["import numpy as np\n","\n","# planet mass in kg\n","# planet radius in m\n","# you can just use the 'e' notation: a*(10**b) == a e b\n","\n","masses = np.array((3.285e23, 5.972e24, 6.39e23, 1.898e27))\n","radii = np.array((2.440e6, 6.371e6, 3.390e6, 69.911e6))\n","G = 6.674e-11\n","names = ['Mercury', 'Earth', 'Mars', 'Jupiter']\n","\n","g = (-G * masses / (radii**2))\n","\n","for i in range(len(masses)):\n"," print ('Acceleration due to gravity at the surface of {a} is {b} m/s^2'.format(a=names[i], b=g[i]))"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"uX_hE_E74Tnw","colab_type":"text"},"source":["**Q2** Plotting various trajectories on different planets:"]},{"cell_type":"code","metadata":{"id":"nu3LXzVF1tic","colab_type":"code","colab":{}},"source":["import matplotlib.pyplot as plt\n","\n","v_i = 100 \n","a_x = 0\n","\n","angle = 45\n","\n","\n","# lets loop through each of those angle values and work out the trajectory\n","for i in range(len(masses)):\n"," \n"," # each projectile gets a unique set of timestamps, so that each one is sampled 100 times\n"," t_max = 2 * v_i * np.sin(np.deg2rad(angle)) / -g[i]\n"," t_step = 0.01\n"," timestamps = np.arange(0, t_max, t_step)\n"," \n"," # we then work out the x/y coordinates of our projectile at each timestamp for that angle\n"," x = v_i * timestamps * np.cos(np.deg2rad(angle)) + (0.5 * a_x * timestamps ** 2)\n"," y = v_i * timestamps * np.sin(np.deg2rad(angle)) + (0.5 * g[i] * timestamps ** 2)\n"," \n"," #print (t_max)\n"," # add that data to the plot, give it a label\n"," plt.plot(x, y, label = names[i])\n","\n","\n","plt.legend()\n","plt.xlabel('Distance / m')\n","plt.ylabel('Height / m')\n","plt.title('The trajectory of a particle launched on various planets')\n","plt.show()"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"_UgmtR1Lnz0i","colab_type":"text"},"source":["**Q3**. Plotting a realistic trajectory and printing the maximum distance on each planet."]},{"cell_type":"code","metadata":{"id":"tb7cywbE4szB","colab_type":"code","colab":{}},"source":["import matplotlib.pyplot as plt\n","\n","v_i = 20 \n","a_x = 0\n","\n","angle = 45\n","\n","max_distance = []\n","\n","\n","# lets loop through each of those angle values and work out the trajectory\n","for i in range(len(masses)):\n"," \n"," # each projectile gets a unique set of timestamps, so that each one is sampled 100 times\n"," t_max = 2 * v_i * np.sin(np.deg2rad(angle)) / -g[i]\n"," t_step = 0.01\n"," timestamps = np.arange(0, t_max, t_step)\n"," \n"," # we then work out the x/y coordinates of our projectile at each timestamp for that angle\n"," x = v_i * timestamps * np.cos(np.deg2rad(angle)) + (0.5 * a_x * timestamps ** 2)\n"," y = v_i * timestamps * np.sin(np.deg2rad(angle)) + (0.5 * g[i] * timestamps ** 2)\n"," \n"," max_distance.append(x[-1])\n"," \n"," #print (t_max)\n"," # add that data to the plot, give it a label\n"," plt.plot(x, y, label = names[i])\n","\n","\n","plt.legend()\n","plt.xlabel('Distance / m')\n","plt.ylabel('Height / m')\n","plt.title('The trajectory of a particle launched on various planets')\n","plt.show()\n","\n","for i in range(len(names)):\n"," print ('Projectile launched from planet {a} reached {b} meters'.format(a=names[i], b=(np.round(max_distance[i],2))))"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"y16mEvqwqcmG","colab_type":"text"},"source":["So it turns out that if you can throw a ball at 20 m/s on Earth, that same ball would hit the 'surface' of Jupiter in just 15m! Equally, you'd easily launch it over 100m on Mercury!"]}]} -------------------------------------------------------------------------------- /how-far-can-we-throw a ball on jupiter"/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /particle-physcis'/README.md: -------------------------------------------------------------------------------- 1 | # in this code i have tried to simulate a projectile launched at an angle and how to plot the trajectory along with working out how far the projectile reached 2 | [![forthebadge](https://forthebadge.com/images/badges/built-by-developers.svg)](https://forthebadge.com) 3 | [![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com) 4 | [![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](https://forthebadge.com) 5 | [![forthebadge](https://forthebadge.com/images/badges/made-with-javascript.svg)](https://forthebadge.com) 6 | [![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com) 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /particle-physcis'/plotting a trajectory of a particle.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "colab_type": "text", 7 | "id": "mug_MpPEExpa" 8 | }, 9 | "source": [ 10 | "# Plotting a trajectory of a particle\n", 11 | "\n", 12 | "\n", 13 | "\n", 14 | "[Here](http://hyperphysics.phy-astr.gsu.edu/hbase/mot.html) is a link to the Hyperphysics section of kinematics, we will be coding up these equations.\n", 15 | "\n", 16 | "[Here](https://www.khanacademy.org/science/physics/one-dimensional-motion/kinematic-formulas/a/what-are-the-kinematic-formulas) is a link to the derivation of those equations, also worth a read to brush up on your kinematics.\n", 17 | "\n" 18 | ] 19 | }, 20 | { 21 | "cell_type": "markdown", 22 | "metadata": { 23 | "colab_type": "text", 24 | "id": "Ve9a2hazbIU7" 25 | }, 26 | "source": [ 27 | "First, we will import the two libraries we used earlier, Numpy and Matplotlib. These will let us do some basic maths, and set up our plot. " 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": null, 33 | "metadata": { 34 | "colab": {}, 35 | "colab_type": "code", 36 | "id": "h2ucdCa8D3J0" 37 | }, 38 | "outputs": [], 39 | "source": [ 40 | "import numpy as np\n", 41 | "import matplotlib.pyplot as plt" 42 | ] 43 | }, 44 | { 45 | "cell_type": "markdown", 46 | "metadata": { 47 | "colab_type": "text", 48 | "id": "pBPGb_4GbtuP" 49 | }, 50 | "source": [ 51 | "We will then set up some initial parameters. We are going to simulate a projectile launched from the ground at an angle and plot the trajectory. \n", 52 | "\n", 53 | "We will define everything in separate 'x' and 'y' dimensions, and simply sum the results.\n", 54 | "\n", 55 | "Firstly, we define the acceleration due to gravity in the x and y direction in units of m/s^2:" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": null, 61 | "metadata": { 62 | "colab": {}, 63 | "colab_type": "code", 64 | "id": "0ig0QMObcTyM" 65 | }, 66 | "outputs": [], 67 | "source": [ 68 | "a_x = 0\n", 69 | "a_y = -9.81 # note the sign of acceleration is downwards" 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "metadata": { 75 | "colab_type": "text", 76 | "id": "e0pxp-TDcmOS" 77 | }, 78 | "source": [ 79 | "Now we will choose an initial velocity in m/s, and an angle we want to launch the projectile from in degrees:" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": null, 85 | "metadata": { 86 | "colab": {}, 87 | "colab_type": "code", 88 | "id": "gm7fXlrecueD" 89 | }, 90 | "outputs": [], 91 | "source": [ 92 | "v_i = 100\n", 93 | "angle = 60" 94 | ] 95 | }, 96 | { 97 | "cell_type": "markdown", 98 | "metadata": { 99 | "colab_type": "text", 100 | "id": "wr3EkLtudKz0" 101 | }, 102 | "source": [ 103 | "Next, we break down this velocity into an x and y component using trigonometry. Take a look at the figure below and check that you can see the equations in Python matching those in the plot:\n", 104 | "\n", 105 | "![alt text](https://i.imgur.com/uks7IpN.png)\n", 106 | "\n", 107 | "Here is where we call `Numpy`, note that `np.sin(angle)` will assume the angle is in radians but we defined *our* angle in degrees. Luckily `Numpy` *also* has a function to convert degrees into radians called `np.deg2rad(angle)`.\n", 108 | "\n", 109 | "Putting these two functions together:\n", 110 | "\n", 111 | "**Note:** When presented with nested brackets, Python will start on the inside and work outwards." 112 | ] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "execution_count": null, 117 | "metadata": { 118 | "colab": {}, 119 | "colab_type": "code", 120 | "id": "sXdmydA76iQy" 121 | }, 122 | "outputs": [], 123 | "source": [] 124 | }, 125 | { 126 | "cell_type": "code", 127 | "execution_count": null, 128 | "metadata": { 129 | "colab": {}, 130 | "colab_type": "code", 131 | "id": "0KHaItNrdpUg" 132 | }, 133 | "outputs": [], 134 | "source": [ 135 | "v_ix = v_i * np.cos(np.deg2rad(angle))\n", 136 | "v_iy = v_i * np.sin(np.deg2rad(angle))" 137 | ] 138 | }, 139 | { 140 | "cell_type": "markdown", 141 | "metadata": { 142 | "colab_type": "text", 143 | "id": "T2fZgB8oeU3H" 144 | }, 145 | "source": [ 146 | "We now need to create a list of points, or timestamps, at which to calculate the x/y position of the projectile as time passes.\n", 147 | "\n", 148 | "We work out how long the projectile will fly for in seconds before it hits the ground (`t_max`), and create a list of interval size `t_step` between 0 and that time.\n", 149 | "\n", 150 | "Using the time-of-flight equation: \n", 151 | "\n", 152 | "![alt text](https://i.imgur.com/4ocn4aU.png)" 153 | ] 154 | }, 155 | { 156 | "cell_type": "code", 157 | "execution_count": null, 158 | "metadata": { 159 | "colab": {}, 160 | "colab_type": "code", 161 | "id": "MgV8uHhyevJF" 162 | }, 163 | "outputs": [], 164 | "source": [ 165 | "t_max = 2 * v_i * np.sin(np.deg2rad(angle)) / -a_y\n", 166 | "t_step = 0.01\n", 167 | "timestamps = np.arange(0, t_max, t_step)" 168 | ] 169 | }, 170 | { 171 | "cell_type": "markdown", 172 | "metadata": { 173 | "colab_type": "text", 174 | "id": "NrTYvbIxfVHm" 175 | }, 176 | "source": [ 177 | "Now, we take those time stamps and plug them into the equation below (once for x and once for y) along with our inital conditions:\n", 178 | "\n", 179 | "![alt text](https://i.imgur.com/krbihbA.png)" 180 | ] 181 | }, 182 | { 183 | "cell_type": "code", 184 | "execution_count": null, 185 | "metadata": { 186 | "colab": {}, 187 | "colab_type": "code", 188 | "id": "keA4zv1AfqdV" 189 | }, 190 | "outputs": [], 191 | "source": [ 192 | "x = v_ix * timestamps + 0.5 * a_x * timestamps**2 \n", 193 | "y = v_iy * timestamps + 0.5 * a_y * timestamps**2" 194 | ] 195 | }, 196 | { 197 | "cell_type": "markdown", 198 | "metadata": { 199 | "colab_type": "text", 200 | "id": "HcooVQrKgCda" 201 | }, 202 | "source": [ 203 | "Lastly, we set up a plot like in the introductory Notebook and plot our results!\n", 204 | "\n" 205 | ] 206 | }, 207 | { 208 | "cell_type": "code", 209 | "execution_count": null, 210 | "metadata": { 211 | "colab": {}, 212 | "colab_type": "code", 213 | "id": "7Uq53KtggJb2" 214 | }, 215 | "outputs": [], 216 | "source": [ 217 | "fig, ax = plt.subplots()\n", 218 | "ax.plot(x, y)\n", 219 | "plt.show()" 220 | ] 221 | }, 222 | { 223 | "cell_type": "markdown", 224 | "metadata": { 225 | "colab_type": "text", 226 | "id": "XlPfHer4gY7y" 227 | }, 228 | "source": [ 229 | "The entire script together is shown below. I've added extra comments to remind us what is going on, this is good practice for when we start writing more complicated code! I've also added a few extra lines in the plotting part to make our plot look nicer.\n", 230 | "\n", 231 | "The curly brackets `{}` in the `plt.title()` line is a way to tell Python to expect some formatting after the string, in this case we want to insert the value of `angle` in the title." 232 | ] 233 | }, 234 | { 235 | "cell_type": "code", 236 | "execution_count": null, 237 | "metadata": { 238 | "colab": {}, 239 | "colab_type": "code", 240 | "id": "g9THFF8Agcqn" 241 | }, 242 | "outputs": [], 243 | "source": [ 244 | "import numpy as np\n", 245 | "import matplotlib.pyplot as plt\n", 246 | "\n", 247 | "# set up intial conditions, all SI units\n", 248 | "a_x = 0\n", 249 | "a_y = -9.81 # note the sign of acceleration is downwards\n", 250 | "\n", 251 | "v_i = 100\n", 252 | "angle = 45\n", 253 | "\n", 254 | "# work out initial velocities in x/y\n", 255 | "v_ix = v_i * np.cos(np.deg2rad(angle))\n", 256 | "v_iy = v_i * np.sin(np.deg2rad(angle))\n", 257 | "\n", 258 | "# set up a list of timestamps to evaluate the velocity\n", 259 | "t_max = 2 * v_i * np.sin(np.deg2rad(angle)) / -a_y\n", 260 | "t_step = 0.01\n", 261 | "timestamps = np.arange(0, t_max, t_step)\n", 262 | "\n", 263 | "# use kinematic equation to work out the x and y velocities\n", 264 | "x = v_ix * timestamps + (0.5 * a_x * timestamps**2)\n", 265 | "y = v_iy * timestamps + (0.5 * a_y * timestamps**2)\n", 266 | "\n", 267 | "# plot the results!\n", 268 | "fig, ax = plt.subplots()\n", 269 | "ax.plot(x, y)\n", 270 | "plt.xlabel('Distance / m')\n", 271 | "plt.ylabel('Height / m')\n", 272 | "plt.title('The trajectory of a particle launched at {} degrees'.format(angle))\n", 273 | "plt.show()" 274 | ] 275 | }, 276 | { 277 | "cell_type": "markdown", 278 | "metadata": { 279 | "colab_type": "text", 280 | "id": "dC8cx8WvJy3Z" 281 | }, 282 | "source": [ 283 | "# Multiple Projectiles\n", 284 | "\n", 285 | "Lets say we wanted to measure the distance our projectile travelled for a variety of starting conditions such as various angles, heights, gravity, or initial velocities.\n", 286 | "\n", 287 | "We *could* simply run the code over and over and manually change the code each time ... but we can do better than that. Plus it would be nice to plot all the results at once for easy comparison.\n", 288 | "\n", 289 | "Here's how we can adapt the above code to plot a few different angles at once. I'll also save the maximum distance for each angle, and print the results.\n", 290 | "\n", 291 | "As before I'll go through the bits of code one at a time, and then put it all together. It's very similar to the previous example but we're adding a loop so we can plot a few trajectories on one graph." 292 | ] 293 | }, 294 | { 295 | "cell_type": "markdown", 296 | "metadata": { 297 | "colab_type": "text", 298 | "id": "q-vFfNk5j58T" 299 | }, 300 | "source": [ 301 | "As before, we'll start with some imports:" 302 | ] 303 | }, 304 | { 305 | "cell_type": "code", 306 | "execution_count": null, 307 | "metadata": { 308 | "colab": {}, 309 | "colab_type": "code", 310 | "id": "nZLYzD3aj_Nq" 311 | }, 312 | "outputs": [], 313 | "source": [ 314 | "import numpy as np\n", 315 | "import matplotlib.pyplot as plt" 316 | ] 317 | }, 318 | { 319 | "cell_type": "markdown", 320 | "metadata": { 321 | "colab_type": "text", 322 | "id": "UrvNyAZNkD-y" 323 | }, 324 | "source": [ 325 | "We then define some physical values for our initial conditions:" 326 | ] 327 | }, 328 | { 329 | "cell_type": "code", 330 | "execution_count": null, 331 | "metadata": { 332 | "colab": {}, 333 | "colab_type": "code", 334 | "id": "kxbo3RLWkWVB" 335 | }, 336 | "outputs": [], 337 | "source": [ 338 | "v_i = 100\n", 339 | "a_x = 0\n", 340 | "a_y = -9.81" 341 | ] 342 | }, 343 | { 344 | "cell_type": "markdown", 345 | "metadata": { 346 | "colab_type": "text", 347 | "id": "kxh5DW9okdxR" 348 | }, 349 | "source": [ 350 | "Now for the angles. Before we had a single value, this time we're going to create a list of angles to use. We will use `np.arange()` which creates evenly spaced values between two numbers at a given interval. In this case we start at 0 degrees and end at 90 degrees in intervals of 10. See [here](https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.arange.html) for more information.\n" 351 | ] 352 | }, 353 | { 354 | "cell_type": "code", 355 | "execution_count": null, 356 | "metadata": { 357 | "colab": {}, 358 | "colab_type": "code", 359 | "id": "jFvE3__Eki1p" 360 | }, 361 | "outputs": [], 362 | "source": [ 363 | "angles = np.arange(0,90,10)\n", 364 | "\n", 365 | "print (angles)" 366 | ] 367 | }, 368 | { 369 | "cell_type": "markdown", 370 | "metadata": { 371 | "colab_type": "text", 372 | "id": "Gg-qe5ZAk9py" 373 | }, 374 | "source": [ 375 | "Now for the loop. Last time we simply called the equations for our initial conditions along with the timestamps and created the single plot.\n", 376 | "\n", 377 | "*This* time we're going to loop through each value of angle, and create a plot for each one and add it to the graph. \n", 378 | "\n", 379 | "Because this is a loop, we can't break it up into multiple cells, but I've added a lot of comments to help understand each line. " 380 | ] 381 | }, 382 | { 383 | "cell_type": "code", 384 | "execution_count": null, 385 | "metadata": { 386 | "colab": {}, 387 | "colab_type": "code", 388 | "id": "Eb1py-Vplu5m" 389 | }, 390 | "outputs": [], 391 | "source": [ 392 | "# lets loop through each of those angle values and work out the trajectory\n", 393 | "for i in range(len(angles)):\n", 394 | " \n", 395 | " # each projectile gets a unique set of timestamps, so that each trajectory curve has 100 samples\n", 396 | " t_max = 2 * v_i * np.sin(np.deg2rad(angles[i])) / -a_y\n", 397 | " t_step = 0.01\n", 398 | " timestamps = np.arange(0, t_max, t_step)\n", 399 | " \n", 400 | " # we then work out the x/y coordinates of our projectile at each timestamp\n", 401 | " # this is identical as before, but this time we're just picking the i-th angle from the list we made earlier\n", 402 | " x = v_i * timestamps * np.cos(np.deg2rad(angles[i])) + (0.5 * a_x * timestamps**2)\n", 403 | " y = v_i * timestamps * np.sin(np.deg2rad(angles[i])) + (0.5 * a_y * timestamps**2)\n", 404 | " \n", 405 | " # add that data to the plot, give it a label\n", 406 | " plt.plot(x, y, label = angles[i])\n", 407 | " # the loop will now repeat for the next angle until we reach the last angle\n", 408 | " \n", 409 | "plt.legend()\n", 410 | "plt.xlabel('Distance / m')\n", 411 | "plt.ylabel('Height / m')\n", 412 | "plt.title('The trajectory of a particle launched at various angles')\n", 413 | "plt.xlim((0,1200))\n", 414 | "plt.show()" 415 | ] 416 | }, 417 | { 418 | "cell_type": "markdown", 419 | "metadata": { 420 | "colab_type": "text", 421 | "id": "RUJqy0OYpr6n" 422 | }, 423 | "source": [ 424 | "You might think that the last line in the loop above will show a new plot each time in the loop, but it simply means 'add this data to the plot'.\n", 425 | "\n", 426 | "We then overwrite the values of `x` and `y` in the next loop iteration for the next angle, and add *that* new data to the plot. Then in the end we plot all the data together.\n", 427 | "\n", 428 | "You may also have noticed the extra bit of code `label = angles[i]`. This gives each line a label, in this case the angle, and we can add these labels to the plot later.\n", 429 | "\n", 430 | "Once the loop is finished we can finally show the plot on the screen with `plt.show()`. I've also added a few extra formatting things like axis labels and a title like before. The `matplotlib` library is clever and auto asigns a new colour to each plot for us.\n", 431 | "\n", 432 | "The line `plt.legend()` simply turns on the legend, and it will display the labels we assigned earlier." 433 | ] 434 | }, 435 | { 436 | "cell_type": "markdown", 437 | "metadata": { 438 | "colab_type": "text", 439 | "id": "GiUAyU75q_De" 440 | }, 441 | "source": [ 442 | "Also as before, I've put everything together in one cell and deleted some of the comments:" 443 | ] 444 | }, 445 | { 446 | "cell_type": "code", 447 | "execution_count": null, 448 | "metadata": { 449 | "colab": {}, 450 | "colab_type": "code", 451 | "id": "i3JH1_lFKq1e" 452 | }, 453 | "outputs": [], 454 | "source": [ 455 | "v_i = 100 \n", 456 | "a_y = -9.81\n", 457 | "a_x = 0\n", 458 | "\n", 459 | "angles = np.arange(0,90,10)\n", 460 | "\n", 461 | "# create an empty array, we'll save a value here for each projectile\n", 462 | "max_distance = []\n", 463 | "\n", 464 | "# lets loop through each of those angle values and work out the trajectory\n", 465 | "for i in range(len(angles)):\n", 466 | " \n", 467 | " # each projectile gets a unique set of timestamps, so that each one is sampled 100 times\n", 468 | " t_max = 2 * v_i * np.sin(np.deg2rad(angles[i])) / -a_y\n", 469 | " t_step = 0.01\n", 470 | " timestamps = np.arange(0, t_max, t_step)\n", 471 | " \n", 472 | " # we then work out the x/y coordinates of our projectile at each timestamp for that angle\n", 473 | " x = v_i * timestamps * np.cos(np.deg2rad(angles[i])) + (0.5 * a_x * timestamps ** 2)\n", 474 | " y = v_i * timestamps * np.sin(np.deg2rad(angles[i])) + (0.5 * a_y * timestamps ** 2)\n", 475 | " \n", 476 | " # this little 'if' loop will take the last x=position of each projectile so we can compare how far they landed\n", 477 | " # BUT, the 1st angle is 0 degrees and doesn't go anyway, so I need to explcity put a '0' as the 1st value in 'max_distances'\n", 478 | " # for all the rest I can just take the last item in the list of x-distances with x[-1]\n", 479 | " # 'append' just means add the end of the list\n", 480 | " if angles[i] == 0:\n", 481 | " max_distance.append(0)\n", 482 | " else:\n", 483 | " max_distance.append(x[-1])\n", 484 | " \n", 485 | " # add that data to the plot, give it a label\n", 486 | " plt.plot(x, y, label = angles[i])\n", 487 | "\n", 488 | "\n", 489 | "plt.legend()\n", 490 | "plt.xlabel('Distance / m')\n", 491 | "plt.ylabel('Height / m')\n", 492 | "plt.title('The trajectory of a particle launched at various angles')\n", 493 | "plt.xlim((0,1200))\n", 494 | "plt.show()" 495 | ] 496 | }, 497 | { 498 | "cell_type": "markdown", 499 | "metadata": { 500 | "colab_type": "text", 501 | "id": "c6VDcUB8rcww" 502 | }, 503 | "source": [ 504 | "Lastly, remember we saved how far each projectile went? We can print these results here by looping through that array:" 505 | ] 506 | }, 507 | { 508 | "cell_type": "code", 509 | "execution_count": null, 510 | "metadata": { 511 | "colab": {}, 512 | "colab_type": "code", 513 | "id": "G8GG3pKrPwvW" 514 | }, 515 | "outputs": [], 516 | "source": [ 517 | "# print a statement by looping through the list of angles and max_distances\n", 518 | "# we also use another Numpy function to round the distance value to 2 dp for neatness\n", 519 | "for i in range(len(angles)):\n", 520 | " print ('Projectile launched at {a} degrees reached {b} meters'.format(a=angles[i], b=np.round(max_distance[i],2)))" 521 | ] 522 | } 523 | ], 524 | "metadata": { 525 | "colab": { 526 | "collapsed_sections": [], 527 | "name": "Copy of Part_2_Simple_Projectile.ipynb", 528 | "private_outputs": true, 529 | "provenance": [ 530 | { 531 | "file_id": "16LxVE0Kmi353HvLBVx1OMj_dISlVxGRr", 532 | "timestamp": 1598850710116 533 | } 534 | ] 535 | }, 536 | "kernelspec": { 537 | "display_name": "Python 3", 538 | "language": "python", 539 | "name": "python3" 540 | }, 541 | "language_info": { 542 | "codemirror_mode": { 543 | "name": "ipython", 544 | "version": 3 545 | }, 546 | "file_extension": ".py", 547 | "mimetype": "text/x-python", 548 | "name": "python", 549 | "nbconvert_exporter": "python", 550 | "pygments_lexer": "ipython3", 551 | "version": "3.7.8" 552 | } 553 | }, 554 | "nbformat": 4, 555 | "nbformat_minor": 1 556 | } 557 | -------------------------------------------------------------------------------- /particle-physcis'/projectile example.py: -------------------------------------------------------------------------------- 1 | ground=box(pos=vector(0,-.2,0),size=vector(10,.4,2),color=color.green) 2 | ball=sphere(pos=vector(-5,1.1,0),radius=.1, color=color.yellow, make_trail=True) 3 | r0=ball.pos 4 | g=vector(0,-9.8,0) 5 | ball.m=0.2 6 | v0=10 7 | theta=70*pi/180 8 | ball.p=ball.m*v0*vector(cos(theta),sin(theta),0) 9 | 10 | t=0 11 | dt=0.001 12 | 13 | while ball.pos.y>=0.1: 14 | rate(1000) 15 | Fnet=ball.m*g 16 | ball.p=ball.p+Fnet*dt 17 | ball.pos=ball.pos+ball.p*dt/ball.m 18 | t=t+dt 19 | 20 | print("dr final = ",ball.pos-r0," m") 21 | print("t final = ",t," s") 22 | -------------------------------------------------------------------------------- /solar-system"/IMG_20200831_123930.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PulsatingGenius/coding-for--physics/c9929135685c2969acba0997d16c08a598a528f2/solar-system"/IMG_20200831_123930.jpg -------------------------------------------------------------------------------- /solar-system"/Readme.md: -------------------------------------------------------------------------------- 1 |

solar system

2 | # In this project i have tried to simulate our solar system.i have also made a code to show the orbital motion of planets using javascript,python,css,html. 3 | 4 |

5 | 6 |

7 | 8 | 9 | -------------------------------------------------------------------------------- /solar-system"/Screenshot (32).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PulsatingGenius/coding-for--physics/c9929135685c2969acba0997d16c08a598a528f2/solar-system"/Screenshot (32).png -------------------------------------------------------------------------------- /solar-system"/rotaional-motion-of-planets"/Screenshot (31).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PulsatingGenius/coding-for--physics/c9929135685c2969acba0997d16c08a598a528f2/solar-system"/rotaional-motion-of-planets"/Screenshot (31).png -------------------------------------------------------------------------------- /solar-system"/rotaional-motion-of-planets"/rotaional-motion-of-planets.css: -------------------------------------------------------------------------------- 1 | //List of planets - used for mixin interation and interpolation 2 | $solarSystem: ("mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto", "sun"); 3 | 4 | //Planet propeties 5 | :root { 6 | --mercury-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/mercury2.jpg); 7 | --mercury-tilt: rotate(0.034deg); 8 | --mercury-day: 1407.6; 9 | --mercury-color: #999999; 10 | --venus-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/venus2.jpg); 11 | --venus-tilt: rotate(177.3deg); 12 | --venus-day: 5832.5; 13 | --venus-color: #e8cda2; 14 | --earth-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/earth.jpg); 15 | --earth-tilt: rotate(23.26deg); 16 | --earth-day: 23.9; 17 | --earth-color: #b3caff; 18 | --mars-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/mars.jpg); 19 | --mars-tilt: rotate(25.2deg); 20 | --mars-day: 24.6; 21 | --mars-color: #c07158; 22 | --jupiter-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/jupiter.jpg); 23 | --jupiter-tilt: rotate(3.1deg); 24 | --jupiter-day: 9.9; 25 | --jupiter-color: #c9b5a4; 26 | --saturn-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/saturn.jpg); 27 | --saturn-tilt: rotate(26.7deg); 28 | --saturn-day: 10.7; 29 | --saturn-color: #f0e2c4; 30 | --uranus-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/uranus2.jpg); 31 | --uranus-tilt: rotate(97.8deg); 32 | --uranus-day: 17.2; 33 | --uranus-color: #b8d8e1; 34 | --neptune-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/neptune.jpg); 35 | --neptune-tilt: rotate(28.3deg); 36 | --neptune-day: 16.1; 37 | --neptune-color: #5e73bb; 38 | --pluto-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/pluto.jpg); 39 | --pluto-tilt: rotate(122.5deg); 40 | --pluto-day: 153.3; 41 | --pluto-color: #c3b6aa; 42 | --sun-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/sun.jpg); 43 | --sun-tilt: rotate(0deg); 44 | --sun-day: 600; 45 | --sun-color: #cc9f4c; 46 | } 47 | 48 | //Mixin for styling each planet 49 | @mixin planetization { 50 | @each $planet in $solarSystem { 51 | &--#{$planet} { 52 | .planet__atmosphere { 53 | box-shadow: inset 10px 0px 12px -2px rgba(255,255,255,.2), 54 | inset -70px 0px 50px 0px black, 55 | -5px 0px 10px -4px var(--#{$planet}-color); 56 | } 57 | .planet__surface { 58 | background-image: var(--#{$planet}-image); 59 | transform: var(--#{$planet}-tilt)scale(1.2); 60 | animation: planetRotate calc(var(--#{$planet}-day)*.1s) linear infinite; 61 | } 62 | .card__planet { 63 | &::before { 64 | transform: var(--#{$planet}-tilt)scale(1.2); 65 | border-color: var(--#{$planet}-color); 66 | color: var(--#{$planet}-color); 67 | } 68 | } 69 | .tilt__icon { 70 | transform: var(--#{$planet}-tilt); 71 | color: var(--#{$planet}-color); 72 | } 73 | } 74 | } 75 | } 76 | 77 | //Planet rotation animation 78 | @keyframes planetRotate { 79 | 0%{ 80 | background-position: 0% center; 81 | } 82 | 100%{ 83 | background-position: -200% center; 84 | } 85 | } 86 | // End definitions 87 | //--------------------------- 88 | //Start styles 89 | body{ 90 | background: #000000; 91 | color: #fff; 92 | height: 100%; 93 | width: 100vw; 94 | margin: 10px 0 40px 0; 95 | display: grid; 96 | grid-template-columns: repeat(auto-fill, 190px); 97 | grid-template-rows: repeat(auto-fill, 400px); 98 | grid-gap: 40px; 99 | align-items: center; 100 | justify-items: center; 101 | justify-content: center; 102 | overflow-x: hidden; 103 | font-family: "Major Mono Display"; 104 | text-transform: lowercase; 105 | } 106 | 107 | 108 | .card { 109 | display: flex; 110 | flex-direction: column; 111 | align-items: center; 112 | position: relative; 113 | @include planetization; 114 | } 115 | 116 | .card__planet { 117 | &::before { 118 | content: ''; 119 | position: absolute; 120 | height: 190px; 121 | z-index: -2; 122 | left: 50%; 123 | top: 0%; 124 | border-left: 1px dashed rgba(255,255,255,.25); 125 | } 126 | } 127 | 128 | .planet { 129 | &__atmosphere { 130 | height: 190px; 131 | width: 190px; 132 | position: relative; 133 | background: radial-gradient(circle at 30% 50%, rgba(255,255,255,.3) 0%, rgba(255,255,255,0) 65%); 134 | border-radius: 100px; 135 | overflow: hidden; 136 | } 137 | &__surface{ 138 | position: absolute; 139 | height: 100%; 140 | width: 100%; 141 | z-index: -1; 142 | background-size: cover; 143 | } 144 | } 145 | 146 | //Different box-shadow for the sun 147 | .card--sun { 148 | .planet__atmosphere { 149 | box-shadow: 0px 0px 10px 0px var(--sun-color), 150 | 0px 0px 1000px -2px var(--sun-color); 151 | } 152 | } 153 | 154 | 155 | .card__info { 156 | width: 100%; 157 | } 158 | 159 | .info { 160 | &__title { 161 | text-align: center; 162 | font-size: 28px; 163 | } 164 | &__form { 165 | display: flex; 166 | flex-direction: column; 167 | justify-content: space-between; 168 | } 169 | &__item { 170 | display: flex; 171 | align-items: flex-end; 172 | margin-bottom: 5px; 173 | font-size: 14px; 174 | .tilt__icon { 175 | margin: 0 5px; 176 | } 177 | } 178 | &__label { 179 | font-size: 11px; 180 | } 181 | &__line { 182 | flex: 1; 183 | margin: 0 5px; 184 | border-bottom: 1px dashed rgba(255,255,255,.3); 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /solar-system"/rotaional-motion-of-planets"/rotaional-motion-of-planets.html: -------------------------------------------------------------------------------- 1 | //- Planet Data 2 | - var planetList = [{"name":"mercury", "tilt":"0.034", "day": "1,407", "year":"88"},{"name":"venus", "tilt":"177.3", "day": "5,832", "year":"224.7"},{"name":"earth", "tilt":"23.26", "day": "23.9", "year":"365.2"},{"name":"mars", "tilt":"25.2", "day": "24.6", "year":"687"},{"name":"jupiter", "tilt":"3.1", "day": "9.9", "year":"4,331"},{"name":"saturn", "tilt":"26.7", "day": "10.7", "year":"10,747"},{"name":"uranus", "tilt":"97.8", "day": "17.2", "year":"30,589"},{"name":"neptune", "tilt":"28.3", "day": "16.1", "year":"59,800"},{"name":"pluto", "tilt":"122.5", "day": "153.3", "year":"90,560"}, {"name":"sun", "tilt":"0", "day": "~600", "year":"0"}]; 3 | 4 | //- Planet Template 5 | each planet in planetList 6 | article(class="card card--"+planet.name) 7 | div(class="card__planet") 8 | div(class="planet__atmosphere") 9 | div(class="planet__surface") 10 | div(class="card__info") 11 | h2(class="info__title")= planet.name 12 | div(class="info__form") 13 | div(class="info__item") 14 | label(class="info__label") Tilt 15 | span(class="info__line") 16 | i(class=" tilt__icon fas fa-long-arrow-alt-right") 17 | span(class="info__detail") #{planet.tilt}° 18 | div(class="info__item") 19 | label(class="info__label") Day 20 | span(class="info__line") 21 | span(class="info__detail") #{planet.day} hours 22 | 23 | div(class="info__item") 24 | label(class="info__label") Year 25 | span(class="info__line") 26 | span(class="info__detail") #{planet.year} days 27 | -------------------------------------------------------------------------------- /solar-system"/solar-system-from-2010-2020.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #17171b; 3 | color: #ffffff; 4 | margin: 0; 5 | font-family: "Space Mono"; 6 | } 7 | svg { 8 | height: 100vh; 9 | width: 100vw; 10 | position: fixed; 11 | top: 50%; 12 | left: 50%; 13 | overflow: visible; 14 | } 15 | 16 | header { 17 | position: fixed; 18 | z-index: 1; 19 | top: 100px; 20 | width: 100vw; 21 | display: flex; 22 | flex-direction: column; 23 | align-items: center; 24 | justify-content: center; 25 | font-size: 14px; 26 | color: rgba(255,255,255,.75); 27 | } 28 | 29 | h1 { 30 | font-size: 14px; 31 | font-weight: 100; 32 | text-transform: uppercase; 33 | margin: 0; 34 | } 35 | 36 | h2{ 37 | font-size: 64px; 38 | color: rgba(255,255,255,1); 39 | font-weight: 100; 40 | margin: 0; 41 | } 42 | 43 | button { 44 | font-family: "Space Mono"; 45 | font-size: 12px; 46 | background: transparent; 47 | color: #fff; 48 | font-weight: 100; 49 | text-transform: uppercase; 50 | padding: 5px 20px; 51 | } 52 | 53 | .solarsystem { 54 | height: 100%; 55 | width: 100%; 56 | position: fixed; 57 | bottom: -35%; 58 | transform: rotate3d(1,0,0,65deg); 59 | } 60 | 61 | .planet { 62 | transform-box: fill-box; 63 | transform-origin: 100% 100%; 64 | } 65 | 66 | .orbit, 67 | .trail { 68 | fill: transparent; 69 | stroke-width: 3; 70 | stroke-opacity: .25; 71 | } 72 | 73 | .trail { 74 | stroke-opacity: 1; 75 | } 76 | -------------------------------------------------------------------------------- /solar-system"/solar-system-from-2010-2020.html: -------------------------------------------------------------------------------- 1 | // Array of planet name, distance from sun in AU, and color - used for each iteration below 2 | - var planets = [{name:"mercury", au:.4, color:"silver"}, {name:"venus", au:.7, color:"goldenrod"}, {name:"earth", au:1, color:"deepskyblue"}, {name:"mars", au:1.5, color:"crimson"}, {name:"jupiter", au:5.2, color:"sandybrown"}, {name:"saturn", au:9.6, color:"gold"}, {name:"uraanus", au:19.2, color:"cyan"}, {name:"neptune", au:30, color:"dodgerblue"}]; 3 | 4 | // Mixin for creating SVG orbit, planet, trail, and mask 5 | mixin planetize(planet, au, color) 6 | -var au = au * 25; // Controls overall zoom level 7 | -var au2 = au* .55; // Necessary value for circular path 8 | -var path = "M0,-"+au+" C"+au2+",-"+au+" "+au+",-"+au2+" "+au+",0 C"+au+","+au2+" "+au2+","+au+" 0,"+au+" C-"+au2+","+au+" -"+au+","+au2+" -"+au+",0 C-"+au+",-"+au2+" -"+au2+",-"+au+" 0,-"+au+" Z"; 9 | // Rectangle for planet's trail 10 | clipPath(id="trail"+planet) 11 | rect(class="mask mask--"+planet, width="0", height="25", y="0") 12 | // Path for orbit 13 | path(class="orbit orbit--"+planet, stroke=color, d=path, id="orbit--"+planet) 14 | // Path for trail, same as orbit - gets exposed by clippath 15 | path(class="trail trail--"+planet, stroke=color, d=path, clip-path="url(#trail"+planet+")") 16 | // Circle for planet 17 | circle(class="planet planet--"+planet, r=3, fill=color) 18 | 19 | 20 | header 21 | h1="The Solar System from 2010 to 2020" 22 | h2(id="year")="2020" 23 | button(id="button", onClick="playAnimation()")="Pause" 24 | 25 | svg(class="solarsystem") 26 | circle(class="sun", r="2", fill="#fff") 27 | 28 | //- Template for each planet 29 | each planet in planets 30 | g(id=planet.name) 31 | +planetize(planet.name,planet.au, planet.color) 32 | 33 | -------------------------------------------------------------------------------- /solar-system"/solar-system-from-2010-2020.js: -------------------------------------------------------------------------------- 1 | gsap.registerPlugin(MotionPathPlugin); 2 | 3 | //Get SVG path data from HTML, derived from Pug mixin 4 | const mercuryOrbit = document.getElementById("orbit--mercury").getAttribute("d"); 5 | const venusOrbit = document.getElementById("orbit--venus").getAttribute("d"); 6 | const earthOrbit = document.getElementById("orbit--earth").getAttribute("d"); 7 | const marsOrbit = document.getElementById("orbit--mars").getAttribute("d"); 8 | const jupiterOrbit = document.getElementById("orbit--jupiter").getAttribute("d"); 9 | const saturnOrbit = document.getElementById("orbit--saturn").getAttribute("d"); 10 | const uranusOrbit = document.getElementById("orbit--uranus").getAttribute("d"); 11 | const neptuneOrbit = document.getElementById("orbit--neptune").getAttribute("d"); 12 | 13 | //Variables 14 | let button = document.getElementById("button"); 15 | let yearDisplay = document.getElementById("year"); 16 | let currentYear = {year:2020}; 17 | let dur = 2; 18 | let ease= "power1.inOut"; 19 | let trail = 50; 20 | let tl = gsap.timeline() 21 | 22 | //Functions 23 | //Update current year display 24 | function countYear() { 25 | yearDisplay.innerHTML = currentYear.year; 26 | } 27 | //Toggle button text 28 | function toggleButtonText() { 29 | if (button.innerHTML == "Play") { 30 | button.innerHTML = "Pause" 31 | } else { 32 | button.innerHTML = "Play" 33 | } 34 | } 35 | //Play and pause the timeline 36 | function playAnimation() { 37 | tl.paused() ? tl.play() : tl.pause(); 38 | toggleButtonText(); 39 | } 40 | 41 | //GSAP ANIMATION TIMELINE 42 | //******************************************************** 43 | 44 | //Animate year count between 2020 and 2010 45 | tl.to(currentYear,{ 46 | year:"-=10", 47 | roundProps:"year", 48 | duration: dur, 49 | ease: ease, 50 | onUpdate:function(){ 51 | countYear(); 52 | }}, 0); 53 | 54 | //Mercury 55 | ///////////////////////////////////////////////////////// 56 | tl.to(".planet--mercury", { 57 | motionPath: { 58 | path: mercuryOrbit, 59 | start: .27, 60 | end: 40.89 61 | }, 62 | duration: dur, 63 | ease: ease, 64 | immediateRender: true 65 | },0); 66 | 67 | tl.to(".mask--mercury", { 68 | motionPath: { 69 | path: mercuryOrbit, 70 | autoRotate: true, 71 | start: .27, 72 | end: 40.89 73 | }, 74 | scaleX: 1, 75 | duration: dur, 76 | ease: ease, 77 | immediateRender: true, 78 | },0); 79 | 80 | tl.to(".mask--mercury", { 81 | width: trail, 82 | duration: dur/2, 83 | ease: ease, 84 | },0); 85 | 86 | tl.to(".mask--mercury", { 87 | width: 0, 88 | duration: dur/2, 89 | ease: ease, 90 | },1); 91 | 92 | tl.fromTo(".mask--mercury",{ 93 | scaleX: -1 }, { 94 | scaleX: -1, duration: dur 95 | }, 0); 96 | 97 | 98 | 99 | //Venus 100 | ///////////////////////////////////////////////////////// 101 | tl.to(".planet--venus", { 102 | motionPath: { 103 | path: venusOrbit, 104 | start: .99, 105 | end: 17.22 106 | }, 107 | duration: dur, 108 | ease: ease, 109 | immediateRender: true 110 | },0); 111 | 112 | tl.to(".mask--venus", { 113 | motionPath: { 114 | path: venusOrbit, 115 | autoRotate: true, 116 | start: .99, 117 | end: 17.22 118 | }, 119 | scaleX: 1, 120 | duration: dur, 121 | ease: ease, 122 | immediateRender: true, 123 | },0); 124 | 125 | tl.to(".mask--venus", { 126 | width: trail, 127 | duration: dur/2, 128 | ease: ease, 129 | },0); 130 | 131 | tl.to(".mask--venus", { 132 | width: 0, 133 | duration: dur/2, 134 | ease: ease, 135 | },1); 136 | 137 | tl.fromTo(".mask--venus",{ 138 | scaleX: -1 }, { 139 | scaleX: -1, duration: dur 140 | }, 0); 141 | 142 | 143 | 144 | 145 | //Earth 146 | ///////////////////////////////////////////////////////// 147 | tl.to(".planet--earth", { 148 | motionPath: { 149 | path: earthOrbit, 150 | start: .72, 151 | end: 10.72 152 | }, 153 | duration: dur, 154 | ease: ease, 155 | immediateRender: true 156 | },0); 157 | 158 | tl.to(".mask--earth", { 159 | motionPath: { 160 | path: earthOrbit, 161 | autoRotate: true, 162 | start: .72, 163 | end: 10.72 164 | }, 165 | scaleX: 1, 166 | duration: dur, 167 | ease: ease, 168 | immediateRender: true, 169 | },0); 170 | 171 | tl.to(".mask--earth", { 172 | width: trail, 173 | duration: dur/2, 174 | ease: ease, 175 | },0); 176 | 177 | tl.to(".mask--earth", { 178 | width: 0, 179 | duration: dur/2, 180 | ease: ease, 181 | },1); 182 | 183 | tl.fromTo(".mask--earth",{ 184 | scaleX: -1 }, { 185 | scaleX: -1, duration: dur 186 | }, 0); 187 | 188 | 189 | 190 | //Mars 191 | ///////////////////////////////////////////////////////// 192 | tl.to(".planet--mars", { 193 | motionPath: { 194 | path: marsOrbit, 195 | start: .39, 196 | end: 5.67 197 | }, 198 | duration: dur, 199 | ease: ease, 200 | immediateRender: true 201 | }, 0); 202 | 203 | tl.to(".mask--mars", { 204 | motionPath: { 205 | path: marsOrbit, 206 | autoRotate: true, 207 | start: .39, 208 | end: 5.67 209 | }, 210 | scaleX: 1, 211 | duration: dur, 212 | ease: ease, 213 | immediateRender: true, 214 | },0); 215 | 216 | tl.to(".mask--mars", { 217 | width: trail, 218 | duration: dur/2, 219 | ease: ease, 220 | },0); 221 | 222 | tl.to(".mask--mars", { 223 | width: 0, 224 | duration: dur/2, 225 | ease: ease, 226 | },1); 227 | 228 | tl.fromTo(".mask--mars",{ 229 | scaleX: -1 }, { 230 | scaleX: -1, duration: dur 231 | }, 0); 232 | 233 | 234 | //Jupiter 235 | ///////////////////////////////////////////////////////// 236 | tl.to(".planet--jupiter", { 237 | motionPath: { 238 | path: jupiterOrbit, 239 | autoRotate: true, 240 | start: .23, 241 | end: 1.07 242 | }, 243 | duration: dur, 244 | ease: ease, 245 | immediateRender: true, 246 | },0); 247 | 248 | 249 | tl.to(".mask--jupiter", { 250 | motionPath: { 251 | path: jupiterOrbit, 252 | autoRotate: true, 253 | start: .23, 254 | end: 1.07 255 | }, 256 | scaleX: 1, 257 | duration: dur, 258 | ease: ease, 259 | immediateRender: true, 260 | },0); 261 | 262 | tl.to(".mask--jupiter", { 263 | width: trail, 264 | duration: dur/2, 265 | ease: ease, 266 | },0); 267 | 268 | tl.to(".mask--jupiter", { 269 | width: 0, 270 | duration: dur/2, 271 | ease: ease, 272 | },1); 273 | 274 | tl.fromTo(".mask--jupiter",{ 275 | scaleX: -1 }, { 276 | scaleX: -1, duration: dur 277 | }, 0); 278 | 279 | 280 | 281 | //Saturn 282 | ///////////////////////////////////////////////////////// 283 | tl.to(".planet--saturn", { 284 | motionPath: { 285 | path: saturnOrbit, 286 | autoRotate: true, 287 | start: .17, 288 | end: .51 289 | }, 290 | duration: dur, 291 | ease: "power1.inOut", 292 | immediateRender: true, 293 | },0); 294 | 295 | tl.to(".mask--saturn", { 296 | motionPath: { 297 | path: saturnOrbit, 298 | autoRotate: true, 299 | start: .17, 300 | end: .51 301 | }, 302 | scaleX: 1, 303 | duration: dur, 304 | ease: ease, 305 | immediateRender: true, 306 | },0); 307 | 308 | tl.to(".mask--saturn", { 309 | width: trail, 310 | duration: dur/2, 311 | ease: ease, 312 | },0); 313 | 314 | tl.to(".mask--saturn", { 315 | width: 0, 316 | duration: dur/2, 317 | ease: ease, 318 | },1); 319 | 320 | tl.fromTo(".mask--saturn",{ 321 | scaleX: -1 }, { 322 | scaleX: -1, duration: dur 323 | }, 0); 324 | 325 | 326 | 327 | //Uranus 328 | ///////////////////////////////////////////////////////// 329 | tl.to(".planet--uranus", { 330 | motionPath: { 331 | path: uranusOrbit, 332 | autoRotate: true, 333 | start: .9, 334 | end: 1.02 335 | }, 336 | duration: dur, 337 | ease: ease, 338 | immediateRender: true, 339 | },0); 340 | 341 | 342 | tl.to(".mask--uranus", { 343 | motionPath: { 344 | path: uranusOrbit, 345 | autoRotate: true, 346 | start: .9, 347 | end: 1.02 348 | }, 349 | scaleX: 1, 350 | duration: dur, 351 | ease: ease, 352 | immediateRender: true, 353 | },0); 354 | 355 | tl.to(".mask--uranus", { 356 | width: trail, 357 | duration: dur/2, 358 | ease: ease, 359 | },0); 360 | 361 | tl.to(".mask--uranus", { 362 | width: 0, 363 | duration: dur/2, 364 | ease: ease, 365 | },1); 366 | 367 | tl.fromTo(".mask--uranus",{ 368 | scaleX: -1 }, { 369 | scaleX: -1, duration: dur 370 | }, 0); 371 | 372 | 373 | 374 | //Neptune 375 | ///////////////////////////////////////////////////////// 376 | tl.to(".planet--neptune", { 377 | motionPath: { 378 | path: neptuneOrbit, 379 | autoRotate: true, 380 | start: .04, 381 | end: .1 382 | }, 383 | duration: dur, 384 | ease: "power1.inOut", 385 | immediateRender: true, 386 | },0); 387 | 388 | tl.to(".mask--neptune", { 389 | motionPath: { 390 | path: neptuneOrbit, 391 | autoRotate: true, 392 | start: .04, 393 | end: .1 394 | }, 395 | scaleX: 1, 396 | duration: dur, 397 | ease: ease, 398 | immediateRender: true, 399 | },0); 400 | 401 | tl.to(".mask--neptune", { 402 | width: trail, 403 | duration: dur/2, 404 | ease: ease, 405 | },0); 406 | 407 | tl.to(".mask--neptune", { 408 | width: 0, 409 | duration: dur/2, 410 | ease: ease, 411 | },1); 412 | 413 | 414 | tl.fromTo(".mask--neptune",{ 415 | scaleX: -1 }, { 416 | scaleX: -1, duration: dur 417 | }, 0); 418 | 419 | //Start and configure timeline 420 | ///////////////////////////////////////////////////////// 421 | tl.yoyo(true).repeat(-1).repeatDelay(.25); 422 | tl.play(); 423 | -------------------------------------------------------------------------------- /solar-system"/solar-system.css: -------------------------------------------------------------------------------- 1 | @import url("https://fonts.googleapis.com/css?family=PT+Sans+Narrow"); 2 | 3 | body { 4 | font: 14px/1.5 "PT Sans Narrow", sans-serif; 5 | background: #080e24 url(http://neography.com/experiment/circles/solarsystem/bg.jpg) repeat; 6 | color: #626668; 7 | } 8 | 9 | /* Solar System Styles */ 10 | ul.solarsystem { 11 | position: relative; 12 | height: 640px; 13 | list-style: none; 14 | -webkit-transition: all 0.09s ease-in; 15 | -moz-transition: all 0.09s ease-in; 16 | -o-transition: all 0.09s ease-in; 17 | 18 | transition: all 0.09s ease-in; 19 | ovqp 20 | erflow: hidden; 21 | } 22 | ul.solarsystem li { 23 | text-indent: -999px; 24 | display: block; 25 | position: absolute; 26 | border: 2px solid #394057; 27 | /* opacity: 0.7;*/ 28 | } 29 | ul.solarsystem li span { 30 | display: block; 31 | position: absolute; 32 | width: 10px; 33 | height: 10px; 34 | -webkit-border-radius: 5px; 35 | -moz-border-radius: 5px; 36 | border-radius: 5px; 37 | } 38 | ul.solarsystem li.active { 39 | border-color: #aa4200; 40 | } 41 | ul.solarsystem li.active.sun, 42 | ul.solarsystem li.active span { 43 | -webkit-transform: scale(1.3); 44 | -moz-transform: scale(1.3); 45 | -o-transform: scale(1.3); 46 | transform: scale(1.3); 47 | } 48 | ul.solarsystem li.active.sun span, 49 | ul.solarsystem li.active.earth .moon { 50 | border: none; 51 | -webkit-box-shadow: none; 52 | -moz-box-shadow: none; 53 | box-shadow: none; 54 | } 55 | ul.solarsystem li.sun { 56 | width: 40px; 57 | height: 40px; 58 | -webkit-border-radius: 20px; 59 | -moz-border-radius: 20px; 60 | border-radius: 20px; 61 | background: #fc3; 62 | background-image: -webkit-gradient( 63 | linear, 64 | left bottom, 65 | left top, 66 | color-stop(0.22, rgb(204,153,0)), 67 | color-stop(1, rgb(255,219,112)) 68 | ); 69 | background-image: -moz-linear-gradient( 70 | center bottom, 71 | rgb(204,153,0) 22%, 72 | rgb(255,219,112) 100% 73 | ); 74 | top: 302px; 75 | left: 462px; 76 | border: none; 77 | -webkit-box-shadow: 0 0 50px #c90; 78 | -moz-box-shadow: 0 0 50px #c90; 79 | box-shadow: 0 0 50px #c90; 80 | z-index: 100; 81 | -webkit-transition: all 0.2s ease-in; 82 | -moz-transition: all 0.2s ease-in; 83 | -o-transition: all 0.2s ease-in; 84 | transition: all 0.2s ease-in; 85 | } 86 | ul.solarsystem li.sun span { 87 | width: 60px; 88 | height: 60px; 89 | -webkit-border-radius: 30px; 90 | -moz-border-radius: 30px; 91 | border-radius: 30px; 92 | } 93 | ul.solarsystem li.mercury { 94 | width: 100px; 95 | height: 100px; 96 | -webkit-border-radius: 52px; 97 | -moz-border-radius: 52px; 98 | border-radius: 52px; 99 | top: 270px; 100 | left: 430px; 101 | z-index: 99; 102 | } 103 | ul.solarsystem li.mercury span { 104 | background: #b6bac5; 105 | top: 10px; 106 | left: 10px; 107 | } 108 | ul.solarsystem li.venus { 109 | width: 160px; 110 | height: 160px; 111 | -webkit-border-radius: 82px; 112 | -moz-border-radius: 82px; 113 | border-radius: 82px; 114 | top: 240px; 115 | left: 400px; 116 | z-index: 98; 117 | } 118 | ul.solarsystem li.venus span { 119 | background: #bf8639; 120 | top: 118px; 121 | left: 5px; 122 | } 123 | ul.solarsystem li.earth { 124 | width: 220px; 125 | height: 220px; 126 | -webkit-border-radius: 112px; 127 | -moz-border-radius: 112px; 128 | border-radius: 112px; 129 | top: 210px; 130 | left: 370px; 131 | z-index: 97; 132 | } 133 | ul.solarsystem li.earth span { 134 | background: #06c; 135 | top: 56px; 136 | left: 5px; 137 | } 138 | ul.solarsystem li.earth span.moon { 139 | width: 4px; 140 | height: 4px; 141 | -webkit-border-radius: 2px; 142 | -moz-border-radius: 2px; 143 | border-radius: 2px; 144 | background: #ccc; 145 | top: 12px; 146 | left: 12px; 147 | } 148 | ul.solarsystem li.mars { 149 | width: 280px; 150 | height: 280px; 151 | -webkit-border-radius: 142px; 152 | -moz-border-radius: 142px; 153 | border-radius: 142px; 154 | top: 180px; 155 | left: 340px; 156 | z-index: 96; 157 | } 158 | ul.solarsystem li.mars span { 159 | background: #aa4200; 160 | top: 0px; 161 | left: 175px; 162 | } 163 | ul.solarsystem li.asteroids_meteorids { 164 | top: 155px; 165 | left: 315px; 166 | z-index: 1; 167 | background: url(http://neography.com/experiment/circles/solarsystem/asteroids_meteorids.png) no-repeat 0 0; 168 | width: 330px; 169 | height: 330px; 170 | -webkit-border-radius: 165px; 171 | -moz-border-radius: 165px; 172 | border-radius: 165px; 173 | border: none; 174 | } 175 | ul.solarsystem li.jupiter { 176 | width: 340px; 177 | height: 340px; 178 | -webkit-border-radius: 172px; 179 | -moz-border-radius: 172px; 180 | border-radius: 172px; 181 | top: 150px; 182 | left: 310px; 183 | z-index: 95; 184 | } 185 | ul.solarsystem li.jupiter span { 186 | background: #e0ae6f; 187 | top: 67px; 188 | left: 24px; 189 | } 190 | ul.solarsystem li.saturn { 191 | width: 400px; 192 | height: 400px; 193 | -webkit-border-radius: 202px; 194 | -moz-border-radius: 202px; 195 | border-radius: 202px; 196 | top: 120px; 197 | left: 280px; 198 | z-index: 94; 199 | } 200 | ul.solarsystem li.saturn span { 201 | background: #dfd3a9; 202 | top: 24px; 203 | left: 300px; 204 | } 205 | ul.solarsystem li.saturn span.ring { 206 | width: 12px; 207 | height: 12px; 208 | -webkit-border-radius: 8px; 209 | -moz-border-radius: 8px; 210 | border-radius: 8px; 211 | background: none; 212 | border: 2px solid #5a4e34; 213 | left: -3px; 214 | top: -3px; 215 | -webkit-transform: skewY(50deg); 216 | -moz-transform: skewY(50deg); 217 | -o-transform: skewY(50deg); 218 | transform: skewY(50deg); 219 | } 220 | ul.solarsystem li.uranus { 221 | width: 460px; 222 | height: 460px; 223 | -webkit-border-radius: 232px; 224 | -moz-border-radius: 232px; 225 | border-radius: 232px; 226 | top: 90px; 227 | left: 250px; 228 | z-index: 93; 229 | } 230 | ul.solarsystem li.uranus span { 231 | background: #82b3d1; 232 | top: 7px; 233 | left: 300px; 234 | } 235 | ul.solarsystem li.neptune { 236 | width: 520px; 237 | height: 520px; 238 | -webkit-border-radius: 262px; 239 | -moz-border-radius: 262px; 240 | border-radius: 262px; 241 | top: 60px; 242 | left: 220px; 243 | z-index: 92; 244 | } 245 | ul.solarsystem li.neptune span { 246 | background: #77c2ec; 247 | top: 0px; 248 | left: 200px; 249 | } 250 | ul.solarsystem li.pluto { 251 | width: 580px; 252 | height: 580px; 253 | -webkit-border-radius: 292px; 254 | -moz-border-radius: 292px; 255 | border-radius: 292px; 256 | top: 30px; 257 | left: 190px; 258 | z-index: 91; 259 | } 260 | ul.solarsystem li.pluto span { 261 | background: #7c6a5c; 262 | top: 79px; 263 | left: 79px; 264 | } 265 | 266 | ul#descriptions { 267 | position: absolute; 268 | top: 150px; 269 | right: 100px; 270 | list-style: none; 271 | } 272 | ul#descriptions h2 { 273 | cursor: pointer; 274 | color: #386077; 275 | -webkit-transition: all 0.15s ease-in; 276 | -moz-transition: all 0.15s ease-in; 277 | -o-transition: all 0.15s ease-in; 278 | transition: all 0.15s ease-in; 279 | font-size: 20px; 280 | position: relative; 281 | z-index: 101; 282 | -webkit-transform: scale(1); 283 | -moz-transform: scale(1); 284 | -o-transform: scale(1); 285 | transform: scale(1); 286 | margin-bottom: -15px; 287 | } 288 | ul#descriptions h2:hover { 289 | color: #aa4200; 290 | -webkit-transform: scale(1.08); 291 | -moz-transform: scale(1.08); 292 | -o-transform: scale(1.08); 293 | transform: scale(1.08); 294 | } 295 | ul#descriptions li p { 296 | position: absolute; 297 | left: -250px; 298 | top: 0; 299 | width: 200px; 300 | display: inline; 301 | opacity: 0; 302 | visibility: hidden; 303 | font-size: 13px; 304 | -webkit-border-radius: 5px; 305 | -moz-border-radius: 5px; 306 | border-radius: 5px; 307 | -webkit-transition: all 0.3s ease-in; 308 | -moz-transition: all 0.3s ease-in; 309 | -o-transition: all 0.3s ease-in; 310 | transition: all 0.3s ease-in; 311 | background: #0f132c; 312 | padding: 30px; 313 | color: #767892; 314 | line-height: 1.7; 315 | z-index: 100; 316 | border: 1px solid #1c203c; 317 | } 318 | ul#descriptions h2:hover+p { 319 | visibility: visible; 320 | opacity: 0.9; 321 | left: -280px; 322 | } 323 | 324 | /* CSS3 Animations */ 325 | ul.solarsystem li { 326 | -webkit-animation-iteration-count:infinite; 327 | -webkit-animation-timing-function:linear; 328 | -webkit-animation-name:orbit; 329 | 330 | -moz-animation-iteration-count:infinite; 331 | -moz-animation-timing-function:linear; 332 | -moz-animation-name:orbit; 333 | } 334 | ul.solarsystem li.earth span { 335 | -webkit-animation-iteration-count:infinite; 336 | -webkit-animation-timing-function:linear; 337 | -webkit-animation-name:moon; 338 | 339 | -moz-animation-iteration-count:infinite; 340 | -moz-animation-timing-function:linear; 341 | -moz-animation-name:moon; 342 | } 343 | ul.solarsystem li.mercury {-webkit-animation-duration:5s; -moz-animation-duration:5s;} 344 | ul.solarsystem li.venus {-webkit-animation-duration:8s; -moz-animation-duration:8s;} 345 | ul.solarsystem li.earth {-webkit-animation-duration:12s; -moz-animation-duration:12s;} 346 | ul.solarsystem li.earth span {-webkit-animation-duration:2s; -moz-animation-duration:2s;} 347 | ul.solarsystem li.mars {-webkit-animation-duration:20s; -moz-animation-duration:20s;} 348 | ul.solarsystem li.asteroids_meteorids {-webkit-animation-duration:50s; -moz-animation-duration:50s;} 349 | ul.solarsystem li.jupiter {-webkit-animation-duration:30s; -moz-animation-duration:30s;} 350 | ul.solarsystem li.saturn {-webkit-animation-duration:60s; -moz-animation-duration:60s;} 351 | ul.solarsystem li.uranus {-webkit-animation-duration:70s; -moz-animation-duration:70s;} 352 | ul.solarsystem li.neptune {-webkit-animation-duration:100s; -moz-animation-duration:100s;} 353 | ul.solarsystem li.pluto {-webkit-animation-duration:120s; -moz-animation-duration:120s;} 354 | 355 | @-webkit-keyframes orbit { from { -webkit-transform:rotate(0deg) } to { -webkit-transform:rotate(360deg) } } 356 | @-webkit-keyframes moon { from { -webkit-transform:rotate(0deg) } to { -webkit-transform:rotate(360deg) } } 357 | 358 | @-moz-keyframes orbit { from { -moz-transform:rotate(0deg) } to { -moz-transform:rotate(360deg) } } 359 | @-moz-keyframes moon { from { -moz-transform:rotate(0deg) } to { -moz-transform:rotate(360deg) } } 360 | 361 | /*ul.solarsystem:hover li {-webkit-animation-play-state: paused;} */ 362 | -------------------------------------------------------------------------------- /solar-system"/solar-system.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 18 | 30 |
31 | 32 | 33 | --------------------------------------------------------------------------------