10 Reputation

One Badge

3 years, 291 days

MaplePrimes Activity

These are replies submitted by akiel123

@acer Sorry about the misunderstanding, I thought you were pointing out a wrong difinition of multiplication between the two functions, and got confused as I couldnt see such a one. The use of lowercase minimze/maximize is a flop on my side too and I changed them to the uppercases - I dont actually know the difference between lower- and uppercase in this instance.
Thanks for your help and sorry if I have offended you :/ For reference changing to uppercase and fixing the multiplication thing seems to have fixed it, and it now just complains about encountering complex numbers, which is expected. If you find time, do you know of a way to make it ignore the imaginary part of any complex numbers encountered and just use the real part?
Sorry about my ignorance

@acer Sorry for the late reply. F__Msl is supposed to be a multiplication between the value returned buy F__s1a and that from b__1, so this is the correct difinition, right?
As for bestangles, I am trying to find the two F__Msl values with lowest difference, based on a configuration of three angles, and the same spring (the length of which is defined by lr__s which in turn is based on theta__4. This is incorrectly defined in the code I see now, but I dont think it should have an impact on the current proble).
The errors further up in the code are a seperate problem that I am working to solve :D But they store the constants they should, and which are relevant for bestangles so I dont think they should have an impact.
As for all the square roots, they are a ton of pythagoras' sentences, which are used to calculate lengths critical to the result, so I unfortuneatly dont think that they can be avoided :/

I made an edited document with most if not all of the irrelevant code removed 


Now that you are at it, do you have any guesses as to what the error further up in the code could be? :P 

whoops, here it is Solving_Cat_Body.mw

@akiel123 The reason theta__ps1p is currently a procedure, is because it was originally intended to just modify p__1x slightly if p__1x and p__2y are the same, so as to avoid division by zero, but for clarity i just put a 1 instead.

@acer Okay, so I worked through a couple of iterations and I cant seem to solve the problem that is telling me that I am dividing by 0 in some tan statement, however I dont see a possibility of division by 0 anywhere, so I am guessing it is some deeper problem. Any suggestions?


theta__ps1P := proc (p__1x, p__1y, p__2x, p__2y) if `p__1x ` = p__2x then p__1x := P__2x+1 end if; return arctan(p__2y-p__1y) end proc:


proc (p__1x, p__1y, p__2x, p__2y) if `p__1x ` = p__2x then p__1x := P__2x+1 end if; return arctan(p__2y-p__1y) end proc



p__s2y := proc (p__2x, p__2y, p__3y, p__4x, p__4y, theta__1, Fh__2) options operator, arrow; (Fh__2-p__4y-p__4x*tan(theta__1)-p__2y+p__2x*tan(theta__1))*cos(theta__1)+p__3y end proc:




OptimizeSpring := proc (p__3x, p__3y, p__4x, p__4y, theta__1, theta__2, FL__1, FL__2, Fh__1, Fh__2, Fmw, d__s, d__j) local a; a := Optimization[Maximize](l__spring(p__1x, p__1y, p__s2x(p__2x, p__2y, p__3y, p__4x, p__4y, theta__1, Fh__2), p__s2y(p__2x, p__2y, p__3y, p__4x, p__4y, theta__1, Fh__2)), {d__minJ(p__s2x(p__2x, p__2y, p__3y, p__4x, p__4y, theta__1, Fh__2), p__s2y(p__2x, p__2y, p__3y, p__4x, p__4y, theta__1, Fh__2), p__1x, p__1y, p__3x, p__3y, d__j, d__s) >= 0, d__minCorner(p__s2x(p__2x, p__2y, p__3y, p__4x, p__4y, theta__2, Fh__2), p__s2y(p__2x, p__2y, p__3y, p__4x, p__4y, theta__2, Fh__2), FL__2, Fh__1, Fmw, d__s, p__1x, p__1y) >= 0, 5 <= p__1x, 5 <= p__1y, 5 <= p__2x, 5 <= p__2y, p__1x <= FL__1, p__1y <= Fh__1-p__s1yConstraint(d__s), p__2x <= FL__2, p__2y <= Fh__2-(1/2)*d__s}); return a end proc:



p3: Joint on type-3 part     p4:joint on type-2 subpart    `&theta;__1`: min angle    `&theta;__2`: Max angle    FL1: Length of type-3 subpart     FL2: length of type-2 subpart    Fh__1: Height of type-3 subpart    Fh__2: Height of type-2 subpart    Fmw: Width of material used for legs    d__s: Max diameter of spring    d__j: Diameter of the joint.


  OptimizeSpring(0, 0, 0, 0, 0, (1/2)*Pi, 40, 40, 40, 40, 0, 1, 0)

Error, (in tan) numeric exception: division by zero




Download ErrorTest.mw

Download ErrorTest.mw


Awesome, it is working now :) replaced degrees with radians and fixde some mistyped theta__1 variables and it works now - not surprisingly there isnt any solutions for the random data in the example but that wasnt really expected either :D Once again, thanks alot!



Alright here goes the document. The reson for making the procedure is to not have to write the two lines of variables every time I have to call it, which is very optimal since I have to use it multiple times throughout the document (there are a multiple spring-sets to optimize) and also, in the end it is supposed to look nice and neat, so it would be prefereable to tug all the ugly details it away in its own section :)


Thanks alot - As you wisely suggested, I moved the operator definitions out of the proc and used the suggest method to do this definition. Also I fixed the stupid error with wrong argument calls :) It now has a problem with d__MinCorner instead of d__min, so I guess that means progress, but as you can see it is still complaining. Checked this time and made sure that all functions are called with the proper amount of arguments :D I changed two obsolete operators into variables, but I dont see a way to convert the other operators to variables (expressions?)

Take two

Page 1 of 1