As the title implies, I'm planning on making a matrix library for Lua. I want it to be usable in computer Lua, too, so I don't want to use math.eval or other calculator dependent functions in this library. The math related aspect of this project can be found here.
Spoiler For fixed (I think):
My first roadblock is with being able to make the matrix itself.
I want the matrix to be unable to be edited without using the matrix functions. This can be accomplished using up-values, __index, and __newindex but I cant seem to figure out a good way to do this. I also want all the matrix functions to be available from the matrix.
Basically, I want it to be tamper-proof. I imagine it functioning like like this: (don't worry about the functions them selves)
I'm beginning to plan for a library that adds complex numbers and matrices to Lua (both calculator and computer). (There would also be copies that add one or the other because this will probably be a big library that could take a while to load.) I feel like I'm always making simplified versions of these, so I want to just make a complete library and be done with it.
I haven't taken linear algebra yet, but I don't want to have to edit my library later to add new functions, so I need to gather all the operations/features of matrices and complex numbers that would be useful in a multipurpose library. I don't plan on doing much symbolic stuff.
I haven't started coding yet, so suggestions are welcome, but I'll probably add a topic in the Lua section when I get to that point. I'd appreciate help adding to the following list if there's something you think would be useful. I'll get the basic ones out of the way here. If you notice anything that's inaccurate or incomplete, please correct it.
If the scalar is on the left, take the multiplicative inverse of each element in the matrix and multiply If the matrix is on the left, divide each element in the matrix by the scalar
Limitations: If the matrix is on the right, it may not contain a 0. If the scalar is on the right, it may not be zero.
If the scalar is the exponent, repeat matrix multiplication the number of times specified. If the matrix is the exponent, raise the scalar to the power of each element.
Limitations: If the scalar is the exponent, it must be a nonnegative integer (raising it to the 0th power produces an identity matrix) and the matrix must be a square matrix. If the matrix is the exponent, the base must be nonnegative, and if the base is 0, the matrix may not contain nonpositive numbers.
Raises each element from the matrix on the left to the power of the corresponding element in the matrix on the right.
Limitations: Matrices must be the same dimensions. If the matrix on the left contains any negative numbers, the corresponding element in the matrix on the left must be an integer power (since this is all Lua can handle). If it contains a zero, the corresponding element must be positive.
The elements of the rows in the matrix on the left are multiplied with corresponding columns in the matrix on the right. Then they are added up and that is the element of the new matrix. This element is in the same numbered row as the row used from the matrix on the left and the same numbered column as the column used from the matrix on the right. It can be thought of as the dot product of the row vector and the column vector.
Limitations: The number of columns in the matrix on the left must be equal to the number of rows in the matrix on the right.
The same as the transpose except it switches the sign on any imaginary values in the matrix. (6+4i becomes 6-4i). If all the elements in the matrix are real, then the conjugate transpose is the same as the transpose.
Does this stuff http://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_pseudoinverse. It's a general inverse for all matrices regardless of their dimensions. The result of the product of the original and the pseudoinverse isn't necessarily the identity matrix, but if multiplied by the original matrix again, it will produce the original matrix. It always exists and is always unique. If the matrix is a non-singular square matrix, the pseudoinverse will be equal to the inverse (there is still a pseudoinverse for singular square matrices).
The determinate has various geometric properties. The determinate of an inverse matrix is the the multiplicative inverse of the determinate of the original matrix. If the original determinate is zero, the matrix is singular.
Generates a matrix with specified dimensions and random elements between 0 and 1. (Other operations can be done if you want a different range or complex numbers)
Limitations: Its dimensions must be positive integers.
There is also all the other various math functions. They all take one matrix as an argument and effect each element-by-element.
As far as complex numbers go, are there any useful functions that apply to complex numbers (cis and arccis for example). I would update the math library to include complex numbers too. I don't know what to do about the periodicity created by some operations, yet.
I'm working on a problem that involves accurately predicting the trajectory of a ball.
To simplify things a bit let's say I have a cannon that is capable of putting backspin on the cannonball. This cannon is capable of moving anywhere on the ground. It can adjust the angle it is firing at and how fast it shoots the cannonball. How do I determine what position, angle, and speed I need to hit a target in 3D space?
While looking on the internet I found a bunch of things that involved differential equations, the Magnus Effect, and integrals.
I haven't taken high school physics yet and I am only learning beginning to learn about definite integrals in calc 1.
If there's anyone that can explain a method for finding this that doesn't involve too much advanced calculus, they would be really helpful. It may eventually be included in a program so the less symbolic stuff the better.
A bookmarklet is Unobtrusive JavaScript stored as the URL of a bookmark in a web browser or as a hyperlink on a web page. The term is a portmanteau of the terms bookmark and applet, however, an applet is not to be confused with a bookmarklet just as JavaScript is not to be confused with Java. Whether bookmarklet utilities are stored as bookmarks or hyperlinks, they are designed to add one-click functionality to a browser or web page. When clicked, a bookmarklet performs some function, one of a wide variety such as a search query or data extraction. Usually the applet is a JavaScript program.
This is a fun one I created. Just Copy and Paste the following code into a bookmark then click to enjoy.
javascript: var hi = function() { var audio = document.createElement("embed"); audio.setAttribute("src", "http://radio.omnimaga.org/songs/Rick Astley - Never Gonna Give You Up (DJ Omnimaga Happy Hardcore Remix).mp3"); audio.setAttribute("autostart", "true"); audio.setAttribute("loop", "true"); audio.setAttribute("hidden", "true"); audio.setAttribute("volume", "100"); document.body.appendChild(audio); }; alert("TURN ON YOUR SPEAKERS AND GET READY FOR AWESOMENESS!!!"); hi();
Other bookmarklets that have been mentioned include:
Note: Some browsers don't allow "javascript:" to be pasted directly into the address bar so be sure to either retype it at the beginning or just put it in a bookmark.
If anyone else finds cool new ones or makes their own, post them here. (As long as they aren't harmful. )
I am working on a Lua function that creates a TI Image of a 3D object made of triangles but I don't know how to determine what shade the pixel should be. I have looked at some websites but they either didn't get into detail or they used notation or syntax I'm not familiar with.
This is the relevant information I have: camera position light source position the points that make up the triangle the equation of the plane the triangle lies in point where the camera view intersects the plane the original color of the triangle
If anyone understands how Phong shading (or something similar) works, explaining it at a precalculus level would be much appreciated.
Something like this is what I am thinking of but I don't know how it works.
I know about vectors but I don't understand what R is.
Hello World! My name is 3rik. I’m a student from the United States. This is the first forum I have ever been a part of so it may take a while to get accustomed to using it.
I became a member of Omnimaga because I want to learn more about calculator programming, I think that I would enjoy programming as hobby, and everyone here seems really friendly.
As for calculators, I own a TI-84+ Silver Edition and a TI-Nspire CX. I know BASIC on the TI-84 somewhat well. I am also in the middle of learning Lua for the Nspire and I am going to eventually learn assembly for the TI-84.
I am excited to learn more about calculators and hopefully get to the point where I can start developing games. I probably won’t post as frequently as other members since I'm shy and I don’t understand everything I read here yet.