I am trying to graph a lemniscate in polar coordinates on scilab. Which formula is
rho^2=a^2*cos(2*theta).
The thing is that calculating the square root of certain values will return an imaginary number as the value would be negative.
clear
close
clc
clf
a=3;
theta=[0:((1*%pi)/180):((359*%pi)/180)];
rr=(a*a)*cos(2*theta);
rho=sqrt(rr);
polarplot(theta,rho,2);
Anyways, the program breaks itself when the negative rr values are reached since the square root is not properly defined for them.
All I need is the code to ignore those points and plot the others.
I don't know if this is understandable, but I hope someone do and can help me with this.
Thanks in advance.
You may ignore (e.g. filter out) those points, but there is an even easier solution: use only the real part of your result vector for the plot with real
polarplot(theta,real(rho),2);
You may also assigh it to a new variable if want to use it later:
rhoreal=real(rho);
Related
I'm working on constraining an IK program so that the normal vector in the end-effector frame is parallel to a known vector in the world-frame, when both are projected to the xy-plane. My initial thought was to use an AddAnglesBetweenVectorsConstraint, but that only allows me to specify the total angle between vectors, and no difference between the different axes. Is there currently a way in Drake to do this?
Edit: it turns out that this was not exactly the problem I needed to solve. In my answer below, I describe the real problem I was solving.
It seems that AddOrientationConstraint will do what you need? If not, then you could accomplish the same with adding two PositionConstraints; I do precisely that in the interactive IK example in the notes for this chapter: https://manipulation.csail.mit.edu/trajectories.html .
Turns out, you can do what I wanted to do using an AddAnglesBetweenVectorsConstraint, I just misdescribed my problem. Specifically, what I really wanted was to do was enforce that the y-axis in the end effector frame (where z-axis is the direction of the end-effector, and the x-axis is straight up in said frame) was perpdinicular both to the z-axis in the world frame and the known vector in the world-frame. This is exactly what AddAngleBetweenVectorsConstraint, and it worked very nicely.
I am trying to save polygon area when a new polygon has been created by the user. I found that there is a function for this purpose - ST_AREA, but when I check if it is calculating correct I find some discrepancies. Here is one example:
This is one polygon which area according to geojson.io is 31.85:
But when I run ST_AREA for the same polygon:
SELECT ST_Area(CONCAT(a.polygon, 'SRID=4326'))*10000 AS area FROM kt_polygons a where polygon_id = 180;
The result is 34.93261884737489. Something more, I am not quite sure why I multiply the result area by 10000.. I just do that because the result seems to be more realistic in that way.
I check some other polygons and the difference is not more than 5, but why this can happen? Any ideas what I do wrong?
I found a solution which helps for my case. When I get the result from ST_Area I multiply it by 9090,91. This coefficient maybe is propriate only for my problem, but you can find if there is dependency between the real areas and the one from ST_Area. If so, you can find your coefficient.
So I have a pretty simple question regarding the size of my data. I am trying to calculate the distance between all sets points (WGS84) in a dataset (56000).
https://www.rdocumentation.org/packages/geosphere/versions/1.5-10/topics/distm
According to the documentation: distm(x,y,fun="") if missing, y is the same as x
mydist<-distm(coordinates(mySpatialObject), fun="distHaversine")
This led me to an Error that y was missing. So I figured I could easily work around this.
distm(coordinates(WeedClim.plot),coordinates(WeedClim.plot), fun="distHaversine")
This leads to not just R:Studio, but my entire computer freezing. I had to to a hard reset twice now and do not want to go through this again, because this is my dissertation and I am afraid of breaking something else in the project XD.
Any ideas/solutions? Is there a better function that gives me a distance matrix from a set of coordinates?
THANKS!
sorry for posting this in programing site, but there might be many programming people who are professional in geometry, 3d geometry... so allow this.
I have been given best fitted planes with the original point data. I want to model a pyramid for this data as the data represent a pyramid. My approach of this modeling is
Finding the intersection lines (e.g. AB, CD,..etc) for each pair of adjacent plane
Then, finding the pyramid top (T) by intersecting the previously found lines as these lines don’t pass through a single point
Intersecting the available side planes with a desired horizontal plane to get the basement
In figure – black triangles are original best fitted triangles; red
and blue triangles are model triangles
I want to show that the points are well fitted for the pyramid model
than that it fitted for the given best fitted planes. (Assume original
planes are updated as shown)
Actually step 2 is done using weighted least square process. Each intersection line is assigned with a weight. Weight is proportional to the angle between normal vectors of corresponding planes. in this step, I tried to find the point which is closest to all the intersection lines i.e. point T. according to the weights, line positions might change with respect to the influence of high weight line. That mean, original planes could change little bit. So I want to show that these new positions of planes are well fitted for the original point data than original planes.
Any idea to show this? I am thinking to use RMSE and show before and after RMSE. But again I think I should use weighted RMSE as all the planes refereeing to the point T are influenced so that I should cope this as a global case rather than looking individual planes….. But I can’t figure out a way to show this. Or maybe I should use some other measure…
So, I am confused and no idea to show this.. Please help me…
If you are given the best-fit planes, why not intersect the three of them to get a single unambiguous T, then determine the lines AT, BT, and CT?
This is not a rhetorical question, by the way. Your actual question seems to be for reassurance that your procedure yields "well-fitted" results, but you have not explained or described what kind of fit you're looking for!
Unfortunately, without this information, your question cannot be answered as asked. If you describe your goals, we may be able to help you achieve them -- or, if you have not yet articulated them for yourself, that exercise may be enough to let you answer your own question...
That said, I will mention that the only difference between the planes you started with and the planes your procedure ends up with should be due to floating point error. This is because, geometrically speaking, all three lines should intersect at the same point as the planes that generated them.
I'm having trouble with Maple.
I have a cosine wave, which I figured out how to plot, but now I have to take samples
from that wave and plot those(as dots) over top of the original cosine wave.
Here is the question from the assignment:
"Produce the samples from Q1 above and plot the result (plot the points on a plot of the cosine wave - use different colours for both, it will look like a cosine wave with dots on it)"
Problem is, my samples keep being straight lines at different heights
http://i197.photobucket.com/albums/aa221/Haseo_Ame/Maple.png
I'm not sure what I'm doing wrong since I've never used maple before.
Firstly, try not to build up lists using repeated concatenation (which can incur an O(n^2) in resources) if you can use the seq command instead (which can incur an O(n) cost in resources). You should always reconsider, when coding like s:=[op(s),...] in a loop.
Next, a point-plot needs pairs of x-y values. Your list is just a collection of scalar values, and hence is being interpreted as a collection of constant functions to be plotted.
The pairs of x-y values can be in a list of (2-element) lists such as [[x1,y1],...,[xn,yn]
It's not clear how you want your x-axis scaled, but you could start off with something like this,
s:=[seq([i, 4*cos(2*Pi*i*70/200+Pi/4)],i=0..20)]:
plot(s, style=point);
# s:=[seq([2*Pi*i*70/200+Pi/4, 4*cos(2*Pi*i*70/200+Pi/4)],i=0..20)]:
ps. Please post source code as text, not as embedded images, so that anyone trying to help needn't type it all in.