Programming
#1
Posted 26 November 2003 - 01:26 PM
I thougth it would be nice to put them here instead in the 'cp300 questions' that should handle more technical about the cp300
#2
Posted 26 November 2003 - 01:37 PM
I want to create a function but it's kinda complex to create just with 'define'
what I want to do is define a vector {a,b,c,d,....,n} it goes on -> calculate it's length en the sum of the lengths
the angle between the vectors.
using define I input this for length: define vlength(a,b,c,d,e,f) = sqrt(a^2+b^2+c^2+d^2+e^2+f^2)
UserC300, thank you for that tip.
but then I would have to type in vlength(1,2,0,0,0,0) , I just want to put any amount of numbers.
I think that would require more skill in programing.
#3
Posted 26 November 2003 - 01:52 PM
#4
Posted 26 November 2003 - 03:53 PM
use a list as the argument to your function, that way you can have any size vector..
what I wrote:
alternatively you can define a function that takes any vector (as a list variable):
define len(v)=sum(v^2)^.5
for using it:
len({1,1,1})
(would give sqrt(3))
#5
Posted 26 November 2003 - 07:21 PM
By the way, why do you need to know the length of a more than 3-dim-Vector?
If someone is interested, I made an eActivity about "Vektoren":
eActivity Vektoren
#6
Posted 26 November 2003 - 09:53 PM
#7
Posted 27 November 2003 - 12:10 AM
btw: at first, when I was just looking at your avatar(kinda scary) and not really reading your post, I misinterpreted it to:
Don`t you ever use 3-dim vectors! (no offence)
#8
Posted 28 November 2003 - 09:17 AM
I did try define len(v)=sum(v^2)^.5didn't you read my post...
define len(v)=sum(v^2)^.5
but instead of v I used x wich somehow didn't work, but I just tried out your method with a v and it worked like a charm
I need it for 5 or more dim vectors.
thnx a million
#9
Posted 28 November 2003 - 10:09 AM
#10
Posted 05 December 2003 - 07:30 AM
but I want to learn more about programming, does anyone know some links??
#11
Posted 05 December 2003 - 09:12 AM
btw: what programming experiance do you have? (if any)
#12
Posted 05 December 2003 - 09:27 AM
Not that much, but still more than just a little
But with calculators none
your dealing with a dummie
#13
Posted 05 December 2003 - 06:00 PM
{data} => {var}
the assignment opperator, takes the data and stores it in a variable, the data can be a string, number, list, or matrix (i think thats all).
1=>A //A now equals 1 "Hi"=>Str //Str contains the string "Hi" {1,2,3}=>Array //Array now contains a 3 dimentionall list [[0,0][0,0]]=>Mat //Mat contains a 2x2 matrix filled with 0's= > < >= <=
these check to see if a condition is true or false, if its false the statement will evaluate to 0 if true it will be 1
lets do a quick program:
Lbl prgm //a Lbl is a marker that can be jumped to durring the program by using Goto {lbl name} InputStr MyName,"Type in your name.","Your Name" // creates an input box that exepts a string, it ask the user for their name and stores it in MyName. StrJoin "Hello ",name,txt //joins "Hello " and name and stores the result in txt Print txt //outputs the text
try playing with that a bit, then I'll give you your next lesson
#14
Posted 07 December 2003 - 03:04 AM
Anyways, a note on the vector length function
If you use the built in vector functions, you probably have your vectors stored in "matrix" format, with '[' and ']' brackets, rather than the list format
To retreive the length of a vector in that format, you can take use of the built in dot product function. Hence the new len(v) function would be defined like this:
define len(v)=dotP(v,v)^.5
#15
Posted 07 December 2003 - 03:10 PM
I created a function wich already excisted namely Crossp()
wich works better 'cause I weren't able to do this in list format.
with Crossp you can use 2 matrix vectors with list it's (1,2,3,4,5,6) instead of {1,2,3},{4,5,6}
It takes a lot of time to learn how to use your CP.
#16
Posted 07 December 2003 - 03:28 PM
If you work alot with vectors, you should switch over to the matrix format and get used to it asap. It makes it much easier to perform, for example, transformations, building arrays of vectors, etc.
#17
Posted 07 December 2003 - 07:30 PM
#18
Posted 07 December 2003 - 07:33 PM
Perhaps I should have a seccond look at that .. what was it called.. aye, manual
#19
Posted 07 December 2003 - 08:58 PM
all what would have been useful for the past trimester to save time...
*feels like an idiot*
#20
Posted 08 December 2003 - 12:44 PM
Crossp = the norm of 2 vectors crossingwhy don't use the norm function ? norm([5,9,1]) = norm of the vector (5,9,1)
#21
Posted 08 December 2003 - 07:04 PM
#22
Posted 15 December 2003 - 01:10 PM
#23
Posted 15 December 2003 - 08:57 PM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users