2009年10月13日

DirectX视口变换矩阵详解

摘要: 视口变换在投影变换之后,视口变换的作用是将投影*面上的点转换为屏幕上的点,这是一个缩放的过程。投影变换的作用是将viewing frustum(视景体)中的场景投影到一个*面上,这个*面就是投影*面,在DirectX中,使用*剪裁*面作为投影*面(z=1),关于透视投影的矩阵求解,请参考透视投影详解视口变换则是将这个cuboid中的物体变换到视口中,见下图。其中cuboid的坐标范围是而viewport的坐标范围是注:由上图知,视口的起点为(X, Y),宽高分别为Width和Height,x轴向右为正,y轴向下为正,y轴的方向与三维坐标正好相反。视口是一个2D*面,但是在viewport变换中 阅读全文

posted @ 2009-10-13 21:17 前端风云志 阅读(8549) 评论(10) 推荐(1)

2009年9月18日

Binary Search

摘要: 简单的二分搜索:在一个非递减序整型数组中搜索值value,返回其所在下标最普通的二分搜索CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1sta... 阅读全文

posted @ 2009-09-18 10:59 前端风云志 阅读(498) 评论(1) 推荐(0)

2009年9月10日

Generate permutation for N elements

摘要: 原理:这个代码好久之前就会了,可是对于其原理一直一知半解其实这个算法的原理和我们手动求全排列的过程是一样的,假设有三个元素a, b, c, 我们求他们的全排列时是按照如下的方法以a开头的有两个a, b, ca, c, b以b开头的有两个b, a, cb, c, a以c开头的有两个c, a, bc, b, a所以一共有六个一般来说,对于给定的n个元素,首先拿出一个元素放到第一个位置,然后对于剩下的n... 阅读全文

posted @ 2009-09-10 16:12 前端风云志 阅读(620) 评论(0) 推荐(0)

2009年9月2日

Z-buffer

摘要: The Z BufferThe Z buffer (also known as a depth buffer) records the depth of a pixel when it is rendered. Because the final transform applied to our geometry takes the data from 3D view space into the... 阅读全文

posted @ 2009-09-02 23:12 前端风云志 阅读(1532) 评论(0) 推荐(0)

2009年8月27日

也谈交换两个变量

摘要: 不使用第三个变量交换两个变量的值,老生常谈了常见的两种方法int a = 1;int b = 2;[代码]最近在园子里看到下面的方法[代码]乍一看,真不敢相信是真的,上机一试还真行,但仅限于C#,在C++下面是不行的看一下反汇编后的代码就一目了然了C#反汇编代码[代码]C++反汇编代码:[代码]可见二者的区别就是,C#在求值过程中保存了b的值,而C++没有总结:此题的本质就是求一种操作X,要保证X... 阅读全文

posted @ 2009-08-27 16:39 前端风云志 阅读(661) 评论(0) 推荐(1)

2009年7月27日

String Comparison

摘要: 字符串比较,请给出输出结果[代码] 阅读全文

posted @ 2009-07-27 15:20 前端风云志 阅读(259) 评论(0) 推荐(0)

参数求值顺序对增量运算符的影响

摘要: 下面的代码输出什么结果?[代码] 阅读全文

posted @ 2009-07-27 14:59 前端风云志 阅读(317) 评论(0) 推荐(0)

任意地址赋值,编译没问题,运行时错误

摘要: ==#include <iostream>using namespace std ;int main(void){ int *p = (int*)1234; //编译没问题,但运行时出错 *p = 190 ; // not writeable system("pause") ; return 0 ;}// output: run time error! access voilation!== 阅读全文

posted @ 2009-07-27 14:53 前端风云志 阅读(412) 评论(1) 推荐(0)

2009年7月2日

Right Hemisphere - A Visual Product Company

摘要: Right HemisphereRight Hemisphere is the leading provider of enterprise product communication and collaboration solutions enabling manufacturers to optimize their global product development launch and ... 阅读全文

posted @ 2009-07-02 16:11 前端风云志 阅读(464) 评论(0) 推荐(0)

2009年6月23日

DP_knapsack

摘要: 动态规划法解0-1背包问题问题描述:有n个背包,重量依次为w1,w2, ... ,wn, 价值依次是v1,v2, ... ,vn, 现在有一个大背包,其容量是capacity,往其中装小背包,要求得到的总价值最大,如何装?用value[i, w]表示有i个背包且总重量最大是w时的价值,那么当考虑第i个背包时,有两种情况1. 将此背包装入大包,价值是 v[i] + value[i - 1, w- w... 阅读全文

posted @ 2009-06-23 16:55 前端风云志 阅读(553) 评论(0) 推荐(0)

2009年6月10日

Maximum Subsequence Multiplication

摘要: Given an array a contains integers, returnthe maximum consecutive multiplication Example:int[] a = {2, -2, -3, 4, -5, 6} ;return 360 (-3 * 4 * -5 * 6)code[代码] 阅读全文

posted @ 2009-06-10 16:02 前端风云志 阅读(464) 评论(0) 推荐(0)

2009年6月9日

Maximum subsequence sum

摘要: This is a very famous problem from programming pealsGiven an array of integers, return the maximum subsequence sum of the array, if the maximus sumless than 0, return 0Example1, 2, -6, 3, -2, 4, -1, 3... 阅读全文

posted @ 2009-06-09 17:08 前端风云志 阅读(419) 评论(0) 推荐(0)

Consecutive sequence with sum 0

摘要: You are given an integer array which contains positive integers, zero and negetive integerscount how many consecutive sequences in this array make a sum of 0.exmapleint[] a = {4, -1, 2, 1, -2, -1, 5, ... 阅读全文

posted @ 2009-06-09 16:26 前端风云志 阅读(410) 评论(0) 推荐(0)

2009年6月7日

Shortest distance between two arrays

摘要: Given two sorted array in non-descending order, each contains positive integersThe distance is define as followingpick up a number from each array, compute their differencereturn the shortest distance... 阅读全文

posted @ 2009-06-07 16:07 前端风云志 阅读(406) 评论(0) 推荐(0)

2009年6月6日

Plateau problem

摘要: Given a sorted array in non-descending order, the element type can be positive integer or char, return the length of the longest consecutive segmentsExample, Input:"1223334556", output 3Input: "abccde... 阅读全文

posted @ 2009-06-06 12:50 前端风云志 阅读(535) 评论(0) 推荐(0)

2009年6月5日

DP_LCS

摘要: The Longest Common Subsequence problemGive two strings a and b. return the length of the longest common subsequence of them.Note: characters in subsequence needn’t to be consecutive, but in subs... 阅读全文

posted @ 2009-06-05 12:01 前端风云志 阅读(570) 评论(1) 推荐(0)

2009年6月4日

一维数组和二维数组的转换表示(C#)

摘要: 关键:下标的计算一维->二维一个n个元素的一维数组,转换为r行c列的二维数组对于一维数组中任意一个元素的下标i(0 <= i < n)其对应的二维数组下标为 (i / c, i % c), 显然, 只与列数c有关,而与行数r无关code like this[代码]also can write like this[代码]二维->一维[代码] 阅读全文

posted @ 2009-06-04 15:00 前端风云志 阅读(23875) 评论(1) 推荐(2)

2009年6月3日

BackTracking_Fixed sum for array elements

摘要: Given an array a contains distinct positive integers, count how many combinations of integers in a add up to exactly sumFor example, given int[] a = {... 阅读全文

posted @ 2009-06-03 16:36 前端风云志 阅读(455) 评论(0) 推荐(0)

BSP 面试总结

摘要: 指针参数 当指针作为函数参数时,对参数本身的修改并不影响原来的值,比如下面的代码,删除链表中第一个值为item的结点。但是结果却不正确。 void Delete(Node *head, int item){ if(head->value == item) head = NULL ;} 这段代码的问题 阅读全文

posted @ 2009-06-03 14:00 前端风云志 阅读(2496) 评论(5) 推荐(0)

2009年5月26日

回溯法解符号三角形

摘要: 消化一个算法最重要的是理解他的思想,而不是急于搞定代码,写文章重要的是阐明道理,而不是简单的粘贴代码,这篇文章需要详细的分析!符号三角形问题是经典的回溯问题,下图是一个符号三角形+ + - ++ - - - + -这个三角形的组成规则是,只能由+和-组成,并且两个相同符号的下面是+,两个不同符号下面是-,设符号三角形第一行有n个符号,对于给定的n,计算有多少种不同的符号三角形,使得+和-的个数相等。例如,当n=4时,共有如下六种符号三角形满足条件+ + - ++ - - - + -+ + - -+ - + - - ++ - + +- - + + - -+ - + -- - - + + +- + 阅读全文

posted @ 2009-05-26 09:30 前端风云志 阅读(1687) 评论(2) 推荐(0)

2009年5月7日

切莫开一块地荒一块地

摘要: 做技术要专注 阅读全文

posted @ 2009-05-07 22:59 前端风云志 阅读(477) 评论(0) 推荐(0)

导航

关注我

前端风云志