<jupyter_start><jupyter_text>Nosecone DesignsThis notbook provides descriptions, equations and renderings of several nose cone shapes commonly used in hobbly rocketry. The notebook leverages serveral common packages such as matplotlib, numpy for data handling and 2D graphing and some less-common packages viewscad, solidpython and OpenSCAD for 3D rendering.Our first step is to import these packages.<jupyter_code># nbi:hide_in
from os.path import expanduser
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
import matplotlib.pyplot as plt
import numpy as np
import viewscad
from solid import *<jupyter_output><empty_output><jupyter_text>L and R define the length and radius of the nosecone and S defines the diameter of the shoulder. M is the diameter of the mount.<jupyter_code># nbi:hide_in
length = 60
radius = 24.8/2
S = 10
Ri = 24.1/2

SMOOTH=100<jupyter_output><empty_output><jupyter_text>This function adds origin coordinates to the arrays passed and plots a graph of the nosecone profile in 2 dimensions. The arrays are combined into an array of points and rotated around the z-axis and outputs an .stl file.<jupyter_code>def render(x, y, name):
    zero = np.array([0])
    base = np.array([Ri])
    shoulder = np.array([-S])

    xplt = np.concatenate((shoulder, shoulder, zero, x, shoulder))
    yplt = np.concatenate((zero, base, base, y, zero))

    plt.axes().set_aspect("equal")    
    plt.plot(xplt, yplt)
    
    r = viewscad.Renderer()
    p = rotate_extrude(360, segments=SMOOTH)(polygon(np.vstack((yplt, xplt)).T))
                                        
    r.render(p, outfile=expanduser("~") + '/' + name + '.stl')<jupyter_output><empty_output><jupyter_text>We define a set of values for X from 0 to the nosecone length.  EllipticalThe elliptical nose cone shape is one-half of an ellipse, with the major axis being the centerline and the minor axis being the base of the nose cone. A rotation of a full ellipse about its major axis is called a prolate spheroid, so an elliptical nose shape would properly be known as a prolate hemispheroid. This shape is popular in subsonic flight (such as model rocketry) due to the blunt nose and tangent base and are generally considered superior for model rocketry altitude optimisation use. This is not a shape normally found in professional rocketry, which almost always flies at much higher velocities where other designs are more suitable.The profile is defined as $y=R{\sqrt  {1-{x^{2} \over L^{2}}}}$ If $R = L$, this is a hemisphere.We define our function, apply that to the values of x to generate an array of y values, which are used to generate a plot of the nosecone profile. The points returned combine the x and y arrays with the addition of the origin point to enure a closed shape.<jupyter_code>x = np.linspace(0, length, int(length * 5))
f = lambda x: radius * np.sqrt(1-(x**2/length**2))
y = f(x)

render(x, y, 'elliptical')<jupyter_output><empty_output><jupyter_text>rotate the profile around the z-axis to create a solid object and output an .stl for subsequent use.  ConicalA very common nose-cone shape is a simple cone. This shape is often chosen for its ease of manufacture, and is also often chosen for its drag and radar cross section characteristics. A lower drag cone would be more streamlined, with the most optimal shape being a Sears-Haack body. The sides of a conical profile are straight lines, so the diameter equation is simply $y={xR \over L}$Cones are sometimes defined by their half angle, $\phi$$\phi = \arctan \Bigl({R \over L}\Bigr)$ and $y = x \tan (\phi) $In practical applications, a conical nose is often blunted by capping it with a segment of a sphere. The tangency point where the sphere meets the cone can be found from$x_t = \frac{L^2}{R}\sqrt{\frac{r_n^2}{R^2+L^2}}$$y_t = \frac{x_tR}{L}$where$r_n$ is the radius of the spherical nose cap.$x_o = x_t + \sqrt{r_n^2 - y_t^2}$$x_a = x_o - r_n$<jupyter_code>f = lambda x: x*radius/length
y = f(x)

points = build_2d(x, y[::-1])
build_3d(points, 'conical')<jupyter_output><empty_output><jupyter_text>ParabolicThis nose shape is not the blunt shape that is envisioned when people commonly refer to a "parabolic" nose cone. The parabolic series nose shape is generated by rotating a segment of a parabola around a line parallel to its latus rectum. This construction is similar to that of the tangent ogive, except that a parabola is the defining shape rather than a circle. Just as it does on an ogive, this construction produces a nose shape with a sharp tip. For the blunt shape typically associated with a parabolic nose, see power series below. (The parabolic shape is also often confused with the elliptical shape.)For $0 \leq K^\prime \leq 1 :  y=R \Biggl({2({x \over L})-K^\prime({x \over L})^{2} \over 2-K^\prime}\Biggr)$$K^\prime$ can vary anywhere between $0$ and $1$, but the most common values used for nose cone shapes are:| Parabola Type | $K^\prime$ Value || --- | --- || Cone | $0$ || Half | $\frac {1}{2}$ || Three Quarter| $3 \over 4$ || Full | $1$ |For the case of the full parabola $(K^\prime = 1)$ the shape is tangent to the body at its base, and the base is on the axis of the parabola. Values of $K^\prime \lt 1$ result in a slimmer shape, whose appearance is similar to that of the secant ogive. The shape is no longer tangent at the base, and the base is parallel to, but offset from, the axis of the parabola.<jupyter_code>K = .75

f = lambda x: radius*(((2*(x/length))-(K*(x/length)**2))/(2-K))
y = f(x)

points = build_2d(x, y[::-1])
build_3d(points, 'parabolic')<jupyter_output><empty_output><jupyter_text>Ogive Tangent ogiveNext to a simple cone, the tangent ogive shape is the most familiar in model/hobby rocketry. The profile of this shape is formed by a segment of a circle such that the rocket body is tangent to the curve of the nose cone at its base, and the base is on the radius of the circle. The popularity of this shape is largely due to the ease of constructing its profile, as it is simply a circular section.The radius of the circle that forms the ogive is called the ''ogive radius'', $\rho$, and it is related to the length and base radius of the nose cone as expressed by the formula$\rho = {R^2 + L^2\over 2R}$The radius $y$ at any point $x$, as $x$ varies from $0$ to $L$ is$y = \sqrt{\rho^2 - (L - x)^2}+R - \rho$The nose cone length, $L$, must be $\leq \rho$. If they are equal, then the shape is a hemisphere. Spherically blunted tangent ogiveA tangent ogive nose is often blunted by capping it with a segment of a [[sphere]].  The tangency point where the sphere meets the tangent ogive can be found from:\begin{align}  x_o &= L - \sqrt{\left(\rho - r_n\right)^2 - (\rho - R)^2} \\  y_t &= \frac{r_n(\rho - R)}{\rho - r_n} \\  x_t &= x_o - \sqrt{r_n^2 - y_t^2}\end{align}where $r_n$ is the radius and $x_o$ is the center of the spherical nose cap.Finally, the apex point can be found from:$x_a = x_o - r_n$<jupyter_code>rho = ((radius**2+length**2)/2*radius)
print(rho)
f = lambda x: np.sqrt((rho**2 - (x-length)**2)) + (radius - rho)
y = f(x)
print(x, y)
yplt = y[::-1]
plt.axes().set_aspect("auto")    
plt.plot(x, yplt)<jupyter_output>23273.312
[ 0.          0.2006689   0.40133779  0.60200669  0.80267559  1.00334448
  1.20401338  1.40468227  1.60535117  1.80602007  2.00668896  2.20735786
  2.40802676  2.60869565  2.80936455  3.01003344  3.21070234  3.41137124
  3.61204013  3.81270903  4.01337793  4.21404682  4.41471572  4.61538462
  4.81605351  5.01672241  5.2173913   5.4180602   5.6187291   5.81939799
  6.02006689  6.22073579  6.42140468  6.62207358  6.82274247  7.02341137
  7.22408027  7.42474916  7.62541806  7.82608696  8.02675585  8.22742475
  8.42809365  8.62876254  8.82943144  9.03010033  9.23076923  9.43143813
  9.63210702  9.83277592 10.03344482 10.23411371 10.43478261 10.63545151
 10.8361204  11.0367893  11.23745819 11.43812709 11.63879599 11.83946488
 12.04013378 12.24080268 12.44147157 12.64214047 12.84280936 13.04347826
 13.24414716 13.44481605 13.64548495 13.84615385 14.04682274 14.24749164
 14.44816054 14.64882943 14.84949833 15.05016722 15.25083612 15.45150502
 15.65217391 15.85284281 16.05351171 16.2[...]<jupyter_text>Haack seriesUnlike all of the nose cone shapes above, the Haack Series shapes are not constructed from geometric figures. The shapes are instead mathematically derived for the purpose of minimizing drag; see also Sears–Haack body. While the series is a continuous set of shapes determined by the value of $C$ in the equations below, two values of $C$ have particular significance: when $C = 0$, the notation $LD$ signifies minimum drag for the given length and diameter, and when $C = {1 \over 3}$, $LV$ indicates minimum drag for a given length and volume. The Haack series nose cones are not perfectly tangent to the body at their base except for the case where $C = {2 \over 3}$. However, the discontinuity is usually so slight as to be imperceptible. For $C > {2 \over 3}$, Haack nose cones bulge to a maximum diameter greater than the base diameter. Haack nose tips do not come to a sharp point, but are slightly rounded.$\theta = \arccos \Bigl(1 - {2X \over L}\Bigr)$$y = {R \over \sqrt{\pi}} \sqrt{\theta-{\sin({2\theta})\over2}+C \sin^3({\theta})}$Where:$C = {1 \over 3}$ for LV-Haack $C = 0$ for LD-Haack<jupyter_code>C = 1/3

f = lambda x: (radius/np.sqrt(np.pi))*np.sqrt((np.arccos(1 - (2*x)/length)) - (np.sin(2 * (np.arccos(1 - (2*x)/length))))/2 + C * np.sin((np.arccos(1 - (2*x)/length)))**3)
y = f(x)

points = build_2d(x, y[::-1])
build_3d(points, 'haak')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10317955112219451, 'fraction_numerical': 0.08987946799667498, 'mean_word_length': 4.092592592592593, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '144525', 'license': 'MIT', 'n_tokens_mistral': 3723, 'n_tokens_neox': 3144, 'n_words': 1300, 'path': 'notebooks/Nosecones.ipynb', 'repo_name': 'rlhatcher/ronald-hatcher-dot-com', 'size': '9624'}