0
$\begingroup$

I am working on a project for school, and I just need to find when the angle between a tangent vector and a line formed between two points. Here is the code I'm using:

v[t_] = Simplify[{{0.95, 0.4, 0.35} - rsSpline[t]}];
angle[t_] = VectorAngle[rsSpline'[t], v[t]]

rsSpline is vector path that is defined earlier, I'll include it at the bottom. When I run this code I get a Tag list in __ is protected. Any ideas on how to get the angle[t] to be evaluated?

rsSpline[t_] = {Piecewise[{{0., 
  t > 20 || t < 0}, {-0.2937381672928643 + 
   0.15040714998600957*t - 0.009814309237081695*t^2 + 
   0.0002765249899592576*t^3, 
  Inequality[40/3, LessEqual, t, LessEqual, 
   20]}, {0.15859527846615362 + 0.048632124690230844*t - 
   0.0021811823398982626*t^2 + 0.00008569681752967245*t^3, 
  Inequality[20/3, LessEqual, t, Less, 40/3]}}, 
0.007407407407407408 + 0.11666666666666667*t - 
 0.012386363636363633*t^2 + 0.0005959558823529409*t^3], 
Piecewise[{{0., 
  t > 20 || t < 0}, {2.3628688879724002 - 0.40432249899261*t + 
   0.03270443866666542*t^2 - 0.0009146400119319888*t^3, 
  Inequality[40/3, LessEqual, t, LessEqual, 
   20]}, {0.5328657794849881 - 0.022883925511597986*t + 
   0.00864336454488792*t^2 - 0.0005404541033524712*t^3, 
  Inequality[0, LessEqual, t, LessEqual, 20/3]}}, 
0.39814521980207296 + 0.03774032634571389*t - 
 0.0004502732337088676*t^2 - 0.00008577221442263185*t^3], 
Piecewise[{{0., 
  t > 20 || t < 0}, {-0.13132189257653604 + 
   0.1485145520804218*t - 0.013373484217090448*t^2 + 
   0.00036857764236616127*t^3, 
  Inequality[40/3, LessEqual, t, LessEqual, 20]}, {0.7 - 
   0.03263184092261795*t - 0.0006726596658646056*t^2 + 
   0.00009531477478562237*t^3, 
  Inequality[0, LessEqual, t, LessEqual, 20/3]}}, 
0.7262268125630266 - 0.04443390657597979*t + 
 0.00109765018213967*t^2 + 6.799282385408284*^-6*t^3]};
$\endgroup$
6
  • $\begingroup$ v[t_] := Simplify[{0.95, 0.4, 0.35} - rsSpline[t]]; angle[t_] := VectorAngle[rsSpline'[t], v[t]]. Note: (i) you should you SetDelayed (ii) the extra curly brackets in v[t] definition lead to the error->remove. $\endgroup$ – ubpdqn Feb 14 '15 at 1:34
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – bbgodfrey Feb 14 '15 at 1:38
  • $\begingroup$ @ubpdqn Thank you, I've fixed those but I still don't have the Tags protected fixed. I'd upvote but I don't have the reputation. $\endgroup$ – Hovestar Feb 14 '15 at 1:44
  • $\begingroup$ @Hovestar I have run the corrected code on a fresh session with no errors, e.g. Table[angle[j], {j, 0.1, 1, 0.1}] yielded {0.0887941, 0.0788714, 0.0691422, 0.0599565, 0.0519149, 0.0459925, \ 0.043476, 0.0453416, 0.0514755, 0.0609099}. So, I suggest saving, quitting kernel and starting fresh session. $\endgroup$ – ubpdqn Feb 14 '15 at 1:48
  • $\begingroup$ @ubpdqn That worked! Could you put that as an answer so I can mark this as completed? $\endgroup$ – Hovestar Feb 14 '15 at 1:51
1
$\begingroup$
v[t_] := Simplify[{0.95, 0.4, 0.35} - rsSpline[t]]; 
angle[t_] := VectorAngle[rsSpline'[t], v[t]]

Note: (i) you should you SetDelayed (ii) the extra curly brackets in v[t] definition lead to the error->remove

I have run the corrected code on a fresh session with no errors, e.g.

Table[angle[j], {j, 0.1, 1, 0.1}]

yielded

{0.0887941, 0.0788714, 0.0691422, 0.0599565, 0.0519149, 0.0459925, 0.043476, 0.0453416, 
  0.0514755, 0.0609099}

So, I suggest saving, quitting kernel and starting fresh session.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.