projection

minimize euclidean distance from sets of points in n-dimensions

偶尔善良 提交于 2020-01-02 20:08:27
问题 Let's look at m points in n-d space- (A solution for 4 points in 3-d space is here: minimize distance from sets of points) a= (x1, y1, z1, ..) b= (x2, y2 ,z2, ..) c= (x3, y3, z3, ..) . . p= (x , y , z, ..) Find point q = c1* a + c2* b + c3* c + .. where c1 + c2 + c3 + .. = 1 and c1, c2, c3, .. >= 0 s.t. euclidean distance pq is minimized. What algorithms can be used ? Idea or pseudocode is enough. (Optimizing performance is a big issue here. Monte Carlo method with all vertices and changing

Conditionally include a field (_id or other) in mongodb project aggregation?

一曲冷凌霜 提交于 2020-01-02 06:59:30
问题 I've got a mongodb aggregation pipeline with a $project stage and I'd like to include certain fields only if conditions are met. Specifically, I'd like to exclude the _id in one condition and include a second field 'second_id' in the other condition. I know that it's not possible (yet) to exclude fields from a mongodb $project, but is it possible to conditionally include them? Is there a way to conditionally exclude the _id field? It accepts a 0 or 1, but what if I want to determine that 0 or

Plotting world map in orthographic projection is giving “non finite points”

*爱你&永不变心* 提交于 2020-01-01 05:49:06
问题 I have a shapefile of world countries, downloaded from here. I can plot it in R using countries <- readOGR("shp","TM_WORLD_BORDERS-0.3",encoding="UTF-8",stringsAsFactors=F) par(mar=c(0,0,0,0),bg=rgb(0.3,0.4,1)) plot(countries,col=rgb(1,0.8,0.4)) Now I wanna plot it in orthographic projection (Earth seen from outer space), so I'm trying countries <- spTransform(countries,CRS("+proj=ortho +lat_0=-10 +lon_0=-60")) I also played with the x_0 and y_0 parameters (as stated here), but I always get

How to deduce the return type of a function object from parameters list?

℡╲_俬逩灬. 提交于 2019-12-31 10:32:40
问题 I'm trying to write a projection function that could transform a vector<T> into a vector<R> . Here is an example: auto v = std::vector<int> {1, 2, 3, 4}; auto r1 = select(v, [](int e){return e*e; }); // {1, 4, 9, 16} auto r2 = select(v, [](int e){return std::to_string(e); }); // {"1", "2", "3", "4"} First attempt: template<typename T, typename R> std::vector<R> select(std::vector<T> const & c, std::function<R(T)> s) { std::vector<R> v; std::transform(std::begin(c), std::end(c), std::back

CreateCriteria with projections does not select all columns

十年热恋 提交于 2019-12-30 11:15:09
问题 My Question is exactly like Grails Projections not returning all properties and not grouped I have a following criteria def sharedDocumentsInstanceList SharedDocuments.createCriteria().list(params){ createAlias('receiver', 'r') createAlias('author', 'a') eq("r.id",session.uid) projections{ groupProperty("a.id") property("a.firstName","firstName") property("a.lastName","lastName") property("a.emailAddress","email") } } Where sharedDocuments is defined as follows class SharedDocuments { Users

What are good reasons to enable 2D projection with cocos2d-iphone?

﹥>﹥吖頭↗ 提交于 2019-12-30 09:58:12
问题 In cocos2d-iphone the default projection type is "3D" projection. But you can also set the projection to "2D" like so: [[CCDirector sharedDirector] setProjection:CCDirectorProjection2D]; Behind the scenes the 3D projection uses perspective projection whereas 2D projection is the OpenGL orthographic projection. The technical details about these two projection modes can be reviewed here, that's not what I'm interested in. What are the benefits and drawbacks of 2D projection for cocos2d users?

Projecting a 3D point to 2D screen space using a perspective camera matrix

a 夏天 提交于 2019-12-30 08:38:11
问题 I am attempting to project a series of 3D points onto the screen using a perspective camera matrix. I do not have world space (or consider it being an identity matrix) and my camera does not have camera space (or consider it an identity matrix), I do have a 4x4 matrix for my object space. I am taking the object matrix and multiplying it by the camera perspective matrix, generated with the following method: Matrix4 createPerspectiveMatrix( Float fov, Float aspect, Float near, Float far ) {

Hibernate criteria query using Max() projection on key field and group by foreign primary key

∥☆過路亽.° 提交于 2019-12-30 06:32:08
问题 I'm having difficulty representing this query (which works on the database directly) as a criteria query in Hibernate (version 3.2.5): SELECT s.* FROM ftp_status s WHERE (s.datetime,s.connectionid) IN (SELECT MAX(f.datetime), f.connectionid FROM ftp_status f GROUP BY f.connectionid); so far this is what I've come up with that doesn't work, and throws a could not resolve property: datetime of: common.entity.FtpStatus error message: Criteria crit = s.createCriteria(FtpStatus.class); crit = crit

How to do a shader to convert to azimuthal_equidistant

南笙酒味 提交于 2019-12-29 09:26:10
问题 I have a 360 texture in Equirectangular Projection. With what GLSL shader can I convert it into a azimuthal equidistant projection? See also: http://earth.nullschool.net/#current/wind/isobaric/500hPa/azimuthal_equidistant=24.64,98.15,169 回答1: I would do it in Fragment shader. bind Equirectangular texture as 2D texture bind projection shader draw Quad covering the screen or target texture store or use the result. In Vertex shader I would: Just pass the vertex coordinates as varying to fragment

How to instantiate and apply directives programmatically?

和自甴很熟 提交于 2019-12-28 01:35:14
问题 I know that in ng2 we have ComponentFactoryResolver that can resolve factories that we can apply to a ViewContainerRef . But, is there something similar for directives? a way to instantiate them and apply them to the projected content from a component? 回答1: No, directives can't be added or removed dynamically. They are only applied to HTML statically added to component templates. What you could do is to enable/disable the directive by passing a parameter ( @Input() ) to the directive to