If the answer to this problem is L=F(w,n), the answer for a tree of height h is L=F(d,n*w/d), where d=sqrt(h^2+w^2).
It seems that the reference answer to the arc length given in the test suite is doubled. This is possibly due to the confusion on the parameter w ("the Width of the base of the tree", which literally means the diameter of the base). But the test suite seems to use w as the radius of the base; thus doubling the final answer. Am I missing something here?
Peng, you're correct. I'll blame that oversight on a bit too much Egg Nog, and change the problem description.
Tim, does the fact that the spiral is also travelling in the Z-direction change the length? Is there a distortion due to the 3-D nature of the spiral? I honestly don't know, which is why I added the helpful hint; in case someone could answer that, did the full 3-D calculation, and came up with a more correct answer. If the length of the 2-D spiral is equal to the 3-D one, then your equation is correct; that's actually how I calculated it originally before realizing that I could just use the base of the tree as a variable instead of both the height and base. Does anyone who can actually do this sort of calculation want to chime in here?
Yes, the height does increase the length. For example, w=4 n=5 h=0 gives L=63.1273, while w=4 n=5 h=8 gives L=64.0530. The formulas I used were r=w*t/(2*n*pi), x=r*cos(t), y=r*sin(t), and z=h*(1-t/(2*n*pi)), and then L is the integral of sqrt(dxdt^2+dydt^2+dzdt^2)*dt from 0 to 2*n*pi.
Got the same results as Tim. My tree was upside down: γ=2∙π∙n, x(θ)=w/γ∙θ∙cos(θ), y(θ)=w/γ∙θ∙sin(θ), z(θ)=h/γ∙θ, L=∫̥ᵞ √(x’²+y’²+z’²)dθ. Anyway, h→∞≡L→∞, proves that h matters.
I wasn't really sure how to model the z-coordinate as a function of height. I had a hunch it would be the case, but I couldn't actually figure out how to do it. Thanks to the smart people in the thread for coming up with the equations for it!
The problem description should mention that the spiral starts at (0,0).
Find the longest sequence of 1's in a binary sequence.
Counting in Finnish
Is X a Fibonacci Matrix?
Replace multiples of 5 with NaN
Derivative of polynomial
Some Assembly Required
Now 20% off!
Return elements unique to either input
Iccanobif numbers 1
A matrix of introverts
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office