geometry-surface

Calculate the horizon of a curved face?

被刻印的时光 ゝ 提交于 2019-12-06 03:31:00
I need to find the 2 points of the visual horizon , of a curved face. I have: XYZ of the 4 corner points XYZ of the 2 curved edge bezier points And I need to calculate either: XY of the horizon points XYZ of the horizon points First off you have to convert your 3D beziers to 2D. If I remember right it's sufficient to project the curves just like you project 3D points for rendering. Afterwards you have to find the extrema of the curves. A small HowTo: Convert your bezier-curve from bezier representation to a polyonomial of the form x(t) = a*t^3 + b*t^2 + c*t + d y(t) = e*t^3 + f*t^2 + g*t + g

pickle saving pygame Surface (python)

为君一笑 提交于 2019-12-06 00:12:51
I tried to save a pygame.Surface but it doesn't let me, error TypeError: can't pickle Surface objects I can make it save surfaces? Or maybe there is another module that can save it ? EXPLANATION: a = pygame.Surface( (5,5) ) file = open("hello", "w") pickle.dump(a, file) I have classes which saves in them Surfaces. As monkey said: You don't want to pickle a surface. But if you really need to save that surfaces' content than use the pygame.image.save() function. If you prefer your surface not to be an actual image file (for whatever reason) you could use the pygame.image.tostring() function

How do I draw a texture-mapped triangle in MATLAB?

邮差的信 提交于 2019-12-05 18:09:13
I have a triangle in (u,v) coordinates in an image. I would like to draw this triangle at 3D coordinates (X,Y,Z) texture-mapped with the triangle in the image. Here, u,v,X,Y,Z are all vectors with three elements representing the three corners of the triangle. I have a very ugly, slow and unsatisfactory solution in which I: extract a rectangular part of the image transform it to 3D space with the transformation defined by the three points draw it with surface finally masking out everything that is not part of the triangle with AlphaData Surely there must be an easier way of doing this? I have

Is there any way to “clear” a surface?

两盒软妹~` 提交于 2019-12-05 06:10:42
Is there any way to clear a surface from anything that has been blitted to it? When I dont care about performance, I use: mysurface.fill((0,0,0)) Which will draw the specified color (black in this case) across the entire surface. Is that what you meant by "clear"? Oh, and you need, of course, to "flip" the surface after doing this for it to be visible on the screen. I don't know what API you're using, so here's a vague answer: In virtually all cases "clearing" a surface simply blits a coloured quad of the same size as the surface onto it. The colour used is whatever you want your clear colour

Calculate the eccentricity of ellipses

你。 提交于 2019-12-04 23:29:29
I've like to calculate the eccentricity of ellipses x, in my example: #Artificial ellipse a <- 1 # semi-major axis e <- x# eccentricity b <- a * sqrt(1 - e^2) # semi-minor axis c <- 1.3 # ellipse area But I need to make this using the ellipse area (c) in the calculation. This is poisible? b = c/(pi*a); x = (sqrt(a^2 - b^2))/a; is the formula you need. Or put togther: x = (sqrt(a^2 - (c/(pi*a))^2))/a; 来源: https://stackoverflow.com/questions/55676436/calculate-the-eccentricity-of-ellipses

How can I create a triangulated sphere using 'isosurface' function of MATLAB

痞子三分冷 提交于 2019-12-04 11:25:27
How can I create a Triangulated sphere with faces of triangles with the same area each one. I want something like this, http://imageshack.us/a/img198/5041/71183923.png and I searched and saw I could use the function isosurface of MATLAB, but the triangles don't have equal area and form and they are essentially squares divided in two with the square diagonal. here's my code: >> [X,Y,Z] = meshgrid(-10:10,-10:10,-10:10); >> V = sqrt(X.^2+Y.^2+Z.^2); >> fv = isosurface(X,Y,Z,V) >> p = patch(fv); >> set(p,'EdgeColor','g') and the result is below: http://imageshack.us/a/img818/7125/72103297.png Use

How to plot a 3d surface graph in MATLAB?

我只是一个虾纸丫 提交于 2019-12-04 11:20:21
I have a dataset like so: | 0.1 0.2 0.3 0.4 ---------------------- 1 | 10 11 12 13 2 | 11 12 13 14 3 | 12 13 14 15 4 | 13 14 15 16 I want to plot a 3D surface graph in matlab such that the column headings will be on the y axis, the row headings will be on the x axis and the remaining values will determine the height of the point on the z axis. I have had a look around at lots of different example and I can't work out how to achieve this. At the moment I have got the following: Y = [0.1 0.2 0.3 0.4]; X = [1 2 3 4]; Z = [10 11 12 13; 11 12 13 14; 12 13 14 15; 13 14 15 16]; Please could someone

How to get rid of pygame surfaces?

家住魔仙堡 提交于 2019-12-03 08:47:30
In the following code, there is not just one circle on the screen at any given point in time. I want to fix this to make it so that it looks like there is only one circle, instead of leaving a smudge trail where ever the mouse cursor has been. import pygame,sys from pygame.locals import * pygame.init() screen = pygame.display.set_mode((640,400),0,32) radius = 25 circle = pygame.Surface([radius*2]*2,SRCALPHA,32) circle = circle.convert_alpha() pygame.draw.circle(circle,(25,46,100),[radius]*2,radius) while True: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit()

Combining scatter plot with surface plot

烈酒焚心 提交于 2019-12-03 02:28:13
How can I combine a 3D scatter plot with a 3D surface plot while keeping the surface plot transparent so that I can still see all the points? sissi_luaty To combine various types of plots in the same graph you should use the function plt.hold(True). The following code plots a 3D scatter plot with a 3D surface plot: from mpl_toolkits.mplot3d import * import matplotlib.pyplot as plt import numpy as np from random import random, seed from matplotlib import cm fig = plt.figure() ax = fig.gca(projection='3d') # to work in 3d plt.hold(True) x_surf=np.arange(0, 1, 0.01) # generate a mesh y_surf=np

Threejs - How to offset all points on a 2d geometry by distance

瘦欲@ 提交于 2019-12-02 10:03:01
Using Three.js, (although I believe this is more math related) I have a set of 2D points that can create a 2D geometry. such as square, rectangle, pentagon, or custom 2D shape. Based of the original 2D shape, I would like to create a method to offset the points inward or outward uniformly in such a way like the attached image. I don't know if there is a simple way to offset/grow/shrink all the points (vector3) uniformly on the 2D shape inward or outward. And if so, it'll be cool if I can offset the points by X distance? Kinda of like saying offset the points on the 2D shape outward or inward